每日一练_136 津津的储蓄计划.
作者:互联网
package cn.itcast.girl.TheBlueCup_02;
import java.util.Scanner;
public class SavingsPlan {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
int month[] = new int[13];
int balance=0;//余额.
int total=0;
// int bankrupt;
boolean flag = true;
for(int i=1;i<=12;i++) {
month[i] = sc.nextInt();
}
for(int i=1;i<=12;i++) {
int difference = 300 - month[i];
if(difference + balance < 0) {
flag = false;
System.out.println(-i);
break;
}else {
int divide = (difference + balance)/100;
balance = (difference + balance)%100;
total += 100*divide;
}
}
if(flag) {
System.out.println((int)(total+total*0.2+balance));
}
}
}
标签:一练,total,津津,System,month,int,difference,136,balance 来源: https://blog.csdn.net/redemption____/article/details/122645033