看看红色代码意思
import java.util.*;
public class Retire
{
public static void main (String[] args )
{
Scanner in=new Scanner (System.in );
System.out.print("How much money will you contribute every year?\n");
double payment= in.nextDouble();
System.out.print("Interest rate in?:\n");
double interestRate= in.nextDouble();
double balance =0;
int year =0;
String input;
do
{
balance+=payment;
double interest =balance*interestRate/100;
balance+=interest;
year++;
System.out.printf("After year %d,you balance is %,.2f%n",year,balance);
System.out.print("Ready to retire?(Y/N)");
input = in.next();
}
while (input.equals("N"));
}
} |