While this is pulled up in Eclipse, it's marked as a syntax error at the line with
do {.
Code
import java.text.DecimalFormat;
import java.util.Scanner;
import javax.swing.JOptionPane;
public class SavingsAccount {
/**
* Program by (myname)
*/
double balance=0, annualIntRate=0, depositAmt, withdrawnAmt, monthlyInt, balancePlusInt;
int moCount=0;
double totalInterest=0, totalDeposits=0, totalWithdrawals=0;
String input, input2, input3;
char repeat = 'Y';
public SavingsAccount(String input, String input2)
{
input = JOptionPane.showInputDialog("What is your account's starting balance?");
balance = Double.parseDouble(input);
input2 = JOptionPane.showInputDialog("What is the annual interest rate?");
annualIntRate = Double.parseDouble(input2);
}
do {
public void deposit (String input3)
{
input3 = JOptionPane.showInputDialog("Enter deposit for Month:");
depositAmt = Double.parseDouble(input3);
balance += depositAmt;
totalDeposits = totalDeposits + depositAmt;
}
public void withdrawal (String input4)
{
input4 = JOptionPane.showInputDialog("Enter withdrawal for Month:");
withdrawnAmt = Double.parseDouble(input4);
balance -= withdrawnAmt;
totalWithdrawals = totalWithdrawals + withdrawnAmt;
}
public void calcMonthlyInt (double monthlyInt)
{
monthlyInt = annualIntRate/12;
}
public void addMonthlyInt (double balancePlusInt)
{
balancePlusInt = monthlyInt * balance;
balance += balancePlusInt;
totalInterest = totalInterest + balancePlusInt;
}
public double getFinalCalculations()
{
JOptionPane.showMessageDialog(null, "Your balance is" + balance);
JOptionPane.showMessageDialog(null, "Your total deposit amount is" + totalDeposits);
JOptionPane.showMessageDialog(null, "Your total withdrawals are" + totalWithdrawals);
JOptionPane.showMessageDialog(null, "Your total interest is" + totalInterest);
}
int y = JOptionPane.showConfirmDialog(
null,
"Calculate month" + moCount +"?",
null, JOptionPane.YES_NO_OPTION);{
moCount++;
while(y != JOptionPane.NO_OPTION);
}}
Why is it showing up as an error?
Also, how do I include the system exit thing with the no option? Will it exit anyway if 'no' is selected?