/* Som ework for you ... use you formula to calulate..just used semo formula
use do while loop to take to input for 4 times only
*/
import javax.swing.JOptionPane;
import java.text.DecimalFormat;
import javax.swing.JFrame;
import javax.swing.JTextArea;
public class Table extends JFrame{
private static JTextArea output;
public Table(){
int lp, ap,mp;
int count=0;
String loanPrincipal = JOptionPane.showInputDialog(null, "Enter Initial Loan Princial", JOptionPane.QUESTION_MESSAGE);
String annualPercentage = JOptionPane.showInputDialog(null, "Enter Annual Percentage", JOptionPane.QUESTION_MESSAGE);
String monthlyPayment = JOptionPane.showInputDialog(null, "Enter MonthlyPayment", JOptionPane.QUESTION_MESSAGE);
if(loanPrincipal!=null && annualPercentage!=null && monthlyPayment!=null){
lp = Integer.parseInt(loanPrincipal);
ap= Integer.parseInt(loanPrincipal);
mp=Integer.parseInt(loanPrincipal);
output = new JTextArea(10,15);
int results = lp * ap; // use your own formula to calculate : this is just a demo
output.append("Loan Principal"+" "+"Annual %"+" "+"Monthly Payment"+" "+"Results");
output.append("\n");
output.append(lp +"\t"+ ap +"\t"+mp+ "\t"+ results);
this.getContentPane().add(output,"Center");
this.setSize(400,600);
this.setLocation(100,200);
this.show();
count++;
}else{
JOptionPane.showMessageDialog(null, "The number is invalid,please try again!", "Error",
JOptionPane.INFORMATION_MESSAGE);
count++;
}
}
public static void main(String[]args){
Table t = new Table();
}
}