I am in my first java class and I am writing an amortization program. I have gotten every thing to work correctly thus far except when I try to put in an outer loop I get the following error:
1 error found:
\gnixon00Lab3Test.java:116: cannot find symbol
symbol : variable restart
location: class gnixon00Lab3Test
Here is my code could you please tell me what it is that I am doing wrong?
import java.text.*;
import java.awt.*;
import javax.swing.*;
import javax.swing.plaf.ColorUIResource;
import java.util.Scanner;
import java.applet.*;
import javax.swing.border.*;
import java.awt.event.*;
public class gnixon00Lab3Test
{
public static void main (String[] args)
{
String input,
paymentText,
interestText,
principleText,
balanceText,
loanText,
yearsText,
yearlyInterestText,
output="";
char newLoan;
int years,
months = 0;
double payment,
yInterest,
mInterest,
loan,
principlePaid,
interestPaid,
balance,
power;
do
{
UIManager um=new UIManager();
NumberFormat currency = NumberFormat.getCurrencyInstance();
NumberFormat percent = new DecimalFormat("0.0#%");
JTextArea textArea = new JTextArea();
JScrollPane scrollPane = new JScrollPane(textArea);
JFrame frame = new JFrame("Amortization");
frame.getContentPane().add(scrollPane, BorderLayout.CENTER);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(new Dimension(520, 360));
frame.setLocationRelativeTo(null);
frame.setVisible(true);
input = JOptionPane.showInputDialog("How much is being applied for?");
loan = Double.parseDouble(input);
loanText = currency.format(loan);
balance = loan;
input = JOptionPane.showInputDialog("How Many Years is the loan for?");
years = Integer.parseInt(input);
yearsText = currency.format(years);
months = years * 12;
input = JOptionPane.showInputDialog("What is the YEARLY interest rate? Example 5.9");
yInterest = Double.parseDouble(input);
yInterest /= 100;
mInterest = yInterest / 12;
interestText = percent.format(yInterest);
power = Math.pow ((1 + mInterest),(months));
payment = (loan * ((mInterest * power)/(power - 1)));
paymentText = currency.format(payment);
output = ("For a loan of " + loanText + "\nwith monthly payments of " + paymentText + " over "
+ years + " year \nat "
+ interestText + " annual interest." +
"\n The amortization table is as follows: ");
output += ("\n" + "\n");
output += ("Month Interest Principal Balance" +
"\n---------------------------------------------------");
output += ("\n" + "\n");
for (int term = 1; term <= (months); term ++)
{
interestPaid = (balance * mInterest);
interestText = currency.format(interestPaid);
principlePaid = (payment - interestPaid);
principleText = currency.format(principlePaid);
balance -= principlePaid;
balanceText = currency.format(balance);
output += (term + " " + interestText + " " + principleText + " " + balanceText + "\n" + "\n");
}
textArea.setText(output);
int restart = JOptionPane.showConfirmDialog(
frame, "Would you like to amortize another loan?",
"Restart?",
JOptionPane.YES_NO_OPTION);
System.out.print (restart);
}
while (restart == JOptionPane.YES_OPTION);
}
}