C语言问题(continue,以及 if)
新手问题,有二。一,下面continue处,换成return num,为何不能实现?
二、下面if那里,第一个语句要加大括号才能成立,只有一句为何要加大括号?
谢谢
#include <stdio.h>
#define RATE1 0.15;
#define RATE2 0.28;
int main()
{
double tax,limit,m;
int num;
printf("Select the type of marriage:\n");
printf("1)SINGLE\t2)HOST\t3)MARRIED_SHARE\n4)MARRIED_DIVORCE\t5)quit\n");
while(1)
{
scanf("%d",&num);
switch(num)
{
case 1:limit=17850.0;break;
case 2:limit=23900.0;break;
case 3:limit=29750.0;break;
case 4:limit=14875.0;break;
case 5:printf("Done!\n");
return 0;
default :printf("Please enter a valid figure:\n");
continue;
}
}
printf("Please enter your income:\n");
scanf("%.2lf",&m);
printf("you have select %d\n",num);
printf("input the pay:");
scanf("%lf",&m);
if (m <= limit)
{ tax = m * RATE1;
}
else
tax = limit * RATE1 + (m - limit) * RATE2;
printf("tax is %.2lf\n",tax);
return 0;
}