T1047-求大佬解答!错哪儿了!
<!--Markdown-->
<!--Markdown-->
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
int n = input.nextInt();
double money = 10000;
double b = 0;
double z = 1;
while (z <= n) {
money = Math.ceil(money * (1 + 0.05) * 100) / 100;
z++;
}
b = money + Math.ceil(money * (1 + 0.05) * 100) / 100 + Math.ceil(money * (1 + 0.05) * (1 + 0.05) * 100) / 100
+ Math.ceil(money * (1 + 0.05) * (1 + 0.05) * (1 + 0.05) * 100) / 100;
System.out.printf("Tuition after " + n + " year: " + "%.2f", money);
System.out.println();
System.out.printf("Tuition for 4 year: " + "%.2f", b);
}
}
Comments: