when I compile this code it gives me the error: cannot find symbol > investmentAmount in the last segment. If I take out said segment:
JOptionPane.showMessageDialog(null, "The total amount you have to pay after 5 years is "
+ Math.pow(investmentAmount(interestRate+1),5));
then the rest of the code works, except that I need that segment of the code to pass. If I take out investmentAmount in this segment, but keep interestRate, then the code works perfectly, and gives me the amount after five years. Why does investmentAmount works earlier in the code and not at the end? Why does interestRate not mess up the code at the end and investmentAmount does? Here's the whole code-
import javax.swing.JOptionPane;
public class Ch3IndLabAssignment
{
public static void main( String [] args )
{
String investorName = JOptionPane.showInputDialog( null, "Please enter your first and last name");
JOptionPane.showMessageDialog(null, "Your name is " + investorName);
String input = JOptionPane.showInputDialog( null, "Please enter your investment amount");
double investmentAmount = Double.parseDouble(input);
JOptionPane.showMessageDialog(null, "Your investment amount is " + investmentAmount);
String input2 = JOptionPane.showInputDialog( null, "Please enter the interest rate as a decimal");
double interestRate = Double.parseDouble(input2);
JOptionPane.showMessageDialog(null, "Your interest rate is " + interestRate);
JOptionPane.showMessageDialog(null, "The total amount you have to pay back after 5 years is " +
Math.pow(investmentAmount(interestRate+1),5));
}
}
Aucun commentaire:
Enregistrer un commentaire