主题:求助,刚学C语言遇到的问题
各位大哥哥,大姐姐,我刚学C语言,运行下列程序
为什么总是在case 1:rate=0.00315;break;报错
,Statement missing ; in function main。
我查查了,没缺;呀。
请赐教。
#include<stdio.h>
main()
{
float money,rate,total;
int year;
printf("Please input money:\n");
scanf("%f",&money);
printf("Please input year:\n");
scanf("%n",&year);
if(year<1)
rate=0.0;
if(year>8)
rate=0.00420;
else
{swtich(year)
{case 1:rate=0.00315;break;
case 2:rate=0.00330;break;
case 3:
case 4:rate=0.00345;break;
case 5:
case 6:
case 7:rate=0.00375;break;
case 8:rate=0.00420;break;
}
}
total=money+money*rate*12*year;
printf("Total=%f",total);
getch();
}
为什么总是在case 1:rate=0.00315;break;报错
,Statement missing ; in function main。
我查查了,没缺;呀。
请赐教。
#include<stdio.h>
main()
{
float money,rate,total;
int year;
printf("Please input money:\n");
scanf("%f",&money);
printf("Please input year:\n");
scanf("%n",&year);
if(year<1)
rate=0.0;
if(year>8)
rate=0.00420;
else
{swtich(year)
{case 1:rate=0.00315;break;
case 2:rate=0.00330;break;
case 3:
case 4:rate=0.00345;break;
case 5:
case 6:
case 7:rate=0.00375;break;
case 8:rate=0.00420;break;
}
}
total=money+money*rate*12*year;
printf("Total=%f",total);
getch();
}