开关语句:讨论条件大于三种
例题
#include <stdio.h>
#include <stdlib.h>
int main()
{
int year,money,amoney;
float rate;
printf("Input money(100以上):");
scanf("%d",&money);
printf("Input year(1/2/3/5/8):");
scanf("%d",&year);
switch(year)
{
case 1:
rate=0.0225;
amoney=money+money*rate;
printf("到期时得到利息和本金合计%d元",amoney);
break;
case 2:
rate=0.0243;
amoney=money+money*rate;
printf("到期时得到利息和本金合计%d元",amoney);
break;
case 3:
rate=0.0270;
amoney=money+money*rate;
printf("到期时得到利息和本金合计%d元",amoney);
break;
case 5:
rate=0.0288;
amoney=money+money*rate;
printf("到期时得到利息和本金合计%d元",amoney);
break;
case 8:
rate=0.0300;
amoney=money+money*rate;
printf("到期时得到利息和本金合计%d元",amoney);
break;
}
return 0;
}