Having some difficulties getting this assignment to work. What, I'm having trouble completing is creating an conditional statement that calculates interest for the amount of years entered by the user at the interest rate they enter and displays it in a message box.
This is my code so far:
import javax.swing.JOptionPane;
import javax.swing.JOptionPane;
public class Investment
{
public static void main(String[] args)
{
String inputInvest;
double invest;
String inputYears;
int years;
String inputRate;
double rate;
int total
JOptionPane.showMessageDialog(null, "Diamond Frizzell\n" + "Assign 4,ITMP 2650\n" + "Java Programming, Spring 2012 CRN 11988\n" + "Due Feb 22,2012");
inputInvest = JOptionPane.showInputDialog(null, "Enter investment amount");
invest = Double.parseDouble(inputInvest);
inputYears = JOptionPane.showInputDialog(null, "Enter number of years");
years =Integer.parseInt(inputYears);
inputRate = JOptionPane.showInputDialog(null, "Enter interest rate (as a decimal)");
rate = Double.parseDouble(inputRate);
total = JOptionPane.showMessageDialog(null, "Your investment at " + invest + total);
}
}
}
I think my loop statement should look like this (see below), but I'm not sure. A little guidance or input would be great. Thanks! I also thing my last, JOption statement isn't right. Well, pretty much I know it isn't right because I get errors when I try and run it.
Loop:
while (year <= years)
{
total = invest * years * rate;
years++;