应该是第13天- class Save {
- public static int save(int money) {
- int day = 0;
- int sum = 0;
- while(sum<money){
- day++;
- if(day % 7 == 0){
- sum += 20;
- sum /= 2;
- }
- else{
- sum += 10;
- }
- System.out.println("第" + day + "天,零花钱:" + sum + "元");
- }
- return day;
- }
- }
- class SaveTest {
- public static void main(String[] args) {
- System.out.println("day=" + new Save().save(100));
- }
- }
复制代码
|
|