public static void main(String[] args)
{
//Enter savings amount
String savingsAmountString = JOptionPane.showInputDialog(
" Enter savings amount");
//Convert string to double
double savingsAmount = Double.parseDouble(savingsAmountString);

//enter interest
String interestRateString = JOptionPane.showInputDialog(
"Enter annual interest rate ");
//Convert String to double
double annualInterestRate = Double.parseDouble(interestRateString);


//Enter number of months
String numberOfMonthsString = JOptionPane.showInputDialog(
"Enter number of months");
//Convert string to double
double numberofMonths = Double.parseDouble(numberOfMonthsString);


//obtain monthly interest rate

double newBalance = savingsAmount * Math.pow((1+annualInterestRate/12),(numberofMonths*12)-1)/annualInterestRate);


String output = "after monts the result is" + newBalance;

JOptionPane.showConfirmDialog(null, output); 

Recommended Answers

Ok. And just what is your problem? You want us to analyze your code making untenable assumptions? Please get real...

Jump to Post

All 2 Replies

Ok. And just what is your problem? You want us to analyze your code making untenable assumptions? Please get real...

that isn't even the entire main method.
it's impossible for us to make anything out of this, let alone know what you are looking for.
but, anyway, you have a ')' too much in your

double newBalance = savingsAmount * Math.pow((1+annualInterestRate/12),(numberofMonths*12)-1)/annualInterestRate);

no doubt your compiler already told you this.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.