I don't know what to do next.
import java.text.DecimalFormat;
import javax.swing.JOptionPane;
public class SavingAccount {
public static void main(String[] args) {
String intRate, stBalance, psMonth, input;
double interRate, startBalance, depositIn, monthWith;
int passMonth;
DecimalFormat dollar = new DecimalFormat("##0.00");
intRate = JOptionPane.showInputDialog("Enter the annual interest rate.");
interRate = Double.parseDouble(intRate);
stBalance = JOptionPane.showInputDialog("Enter the starting balance.");
startBalance = Double.parseDouble(stBalance);
SAccount sAccount = new SAccount(startBalance, interRate);
psMonth = JOptionPane.showInputDialog("Enter the number of months that have passed since the account was established.");
passMonth = Integer.parseInt(psMonth);
for(int i = passMonth; i < 12; i++){
input = JOptionPane.showInputDialog("Input the amount of money you want to deposit.");
depositIn = Double.parseDouble(input);
sAccount.setDeposit(depositIn);
input = JOptionPane.showInputDialog("Input the amount of money you want to withdraw.");
monthWith = Double.parseDouble(input);
sAccount.setWithdrawal(monthWith);
sAccount.setTotalInt(interRate);
}JOptionPane.showMessageDialog(null, "total ending balance : " + dollar.format(sAccount.getBalance()) +
"\ntotal amount of deposit : " + dollar.format(sAccount.getDeposit()) +
"\ntotal amount of withdral : " + dollar.format(sAccount.getwithdral()) +
"\ntotal interest you earned : " + dollar.format(sAccount.getTotalInt()));
System.exit(0);
}
}
public class SAccount {
private double interestRate, interest;
private double balance;
private double deposit;
private double withdral;
public SAccount(double bal,double intRate){
balance = bal;
interestRate = intRate;
}
public void setDeposit(double dposit){
deposit += dposit;
}
public void setWithdrawal(double withd){
withdral -= withd;
}
public void setIntRate(double rate){
interestRate = rate;
}
public void setBalance(double bal){
balance = bal;
balance = deposit - withdral;
balance += balance;
}
public void setTotalInt(double intRate){
interestRate = intRate;
interest = (interestRate / 12) * balance;
}
public double getDeposit(){
return deposit;
}
public double getwithdral(){
return withdral;
}
public double getBalance(){
return balance;
}
public double getTotalInt(){
return interest;
}
}

New Topic/Question
Reply



MultiQuote




|