CPRIMERPLUS6 P215 第10题

练习题 | 2020-11-18 21:57:48 | 阅读 45 次 | 评论(0)

#include <stdio.h>
//#include <string.h>

#define sin 17850
#define huz 23900
#define yig 29750
#define yil 14875
#define ftax 0.15
#define stax 0.28


void menu(void);
void star(int i);
double single(int doll,int base);
double huzhu(int doll);




int main(void)
{
char ch;
int gzi,base1;
do{
menu();
printf("\nchoice:");
scanf(" %c",&ch);
switch(ch)
{
case '1':base1=sin;break;
case '2':base1=huz;break;
case '3':base1=yig;break;
case '4':base1=yil;break;
case '5':break;
default:printf("error,please retry:\n");
//getchar();
//scanf(" %c",&ch);
}
if(ch=='1'||ch=='2'||ch=='3'||ch=='4')
{
printf("input gongzi:");
scanf("%d",&gzi);
printf("\nThe tax is:%.2f!! Oh,my GOD!\n\n",single(gzi,base1));
    }}while(ch!='5');

printf("\n\n\n感谢使用"); 
return 0;

}


double single(int doll,int base)
{
double tax;
if(doll<=base) tax=doll*ftax;
else tax=(doll-base)*stax+base*ftax;
return tax;
}
void menu(void)
{
star(50);
printf("\n");
printf("1) 单身\t\t\t\t2) 户主");
printf("\n3) 已婚,共有\t\t\t4) 已婚,离异");
printf("\n5) 退出系统"); 
printf("\n"); 
star(50);
}


void star(int i)
{
for(int j=0;j<i;j++)
{
printf("*");
}
//printf("\n");
}



文章评论,共0条
游客请输入验证码
浏览10011次