预测未来的学费

假设某个大学今年的学费是10000美金,且以每年7%的速度增加。多少年后学费会翻倍?

import java.util.*;
class Main {
  public static void main(String[] args){
    double tuition = 10000;
    int year = 1;
    while(tuition < 20000){
      tuition = tuition * 1.07;
      year++;
    }
    System.out.println("Tuition will be doubled in " + year + " years");
  }
}
posted @ 2022-05-20 11:05  Scenery_Shelley  阅读(87)  评论(0)    收藏  举报