c primer plus第六版第七章编程练习
2020-04-21 21:09
52 查看
//习题八 #include<stdio.h> #include<stdlib.h> #define first_tax 0.15 #define second_tax 0.2 #define last_tax 0.25 #define A 8.75 #define B 9.33 #define C 10.00 #define D 11.20 #define E "quit" void exit(int value); void main() { float Allmoney,hours,tax,realmoney; int i,j; while(1) { for(i=1;i<20;i++) printf("*"); printf("\n"); printf("Enter the number corresponding to the desired pay rate or action:\n"); printf("1)$%.2f\\hr \t 2)$%.2f\\hr \n3)$%.2f\\hr \t 4)$%.2f\\hr \n5)$%s\\hr \n",A,B,C,D,E); for(i=1;i<20;i++) printf("*"); printf("\n"); while(1) { scanf("%d",&j); if(j>=1 && j<=4) { printf("How many hours you will work:"); scanf("%f",&hours); break; } else if(j=5) { exit(1); break; } else { printf("you wrong,enter again:"); continue; } } break; } if(hours>40) hours*=1.5; switch(j) { case 1:Allmoney=hours*A;break; case 2:Allmoney=hours*B;break; case 3:Allmoney=hours*C;break; case 4:Allmoney=hours*D;break; default:break; } if(Allmoney<300) tax=first_tax*Allmoney; else if(Allmoney>300 && Allmoney<450) tax=first_tax*300 + second_tax*(Allmoney-300); else tax=first_tax*300 + second_tax*150 + last_tax*(Allmoney-450); realmoney=Allmoney-tax; printf("工资总额:%.3f\t税金:%.3f\t净收入:%.3f\n",Allmoney,tax,realmoney); } void exit(int vaue) { }
//习题九 #include<stdio.h> #define single 17850 #define head 23900 #define married 29750 #define divoiced 14875 void main() { float selfmoney,tax; int i,j; for(i=1;i<40;i++) printf("*"); printf("\n"); printf("Please enter your state :\n"); printf("1>single\t 2>head \n3>married\t 4>divoiced\t 5>quit\n"); for(i=1;i<40;i++) printf("*"); printf("\n"); while(1) { scanf("%d",&j); if(j==5) break; switch(j) { case 1: { printf("enter your money:"); scanf("%f",&selfmoney); if(selfmoney<=single) tax=selfmoney*0.15; else tax=single*0.15 + (selfmoney-single)*0.28; };break; case 2: { printf("enter your money:"); scanf("%f",&selfmoney); if(selfmoney<=head) tax=selfmoney*0.15; else tax=head*0.15 + (selfmoney-head)*0.28; };break; case 3: { printf("enter your money:"); scanf("%f",&selfmoney); if(selfmoney<=married) tax=selfmoney*0.15; else tax=married*0.15 + (selfmoney-head)*0.28; };break; case 4: { printf("enter your money:"); scanf("%f",&selfmoney); if(selfmoney<=divoiced) tax=selfmoney*0.15; else tax=divoiced*0.15 + (selfmoney-head)*0.28; };break; default:printf("wrong data,enter again"); continue; } printf("selfmoney:%.2f\t tax:%.2f",selfmoney,tax); } }
相关文章推荐
- C.Primer.Plus(第六版)第七章 编程练习
- C Primer Plus (第六版)中文版 第七章 编程练习答案
- C ++ Primer Plus 第六版 第七章编程练习答案
- c primer plus 第六版 第七章编程练习答案
- C Primer Plus 第六版编程练习第七章答案和记录一些学习历程
- 【学习C++】C++ Primer Plus (第六版)第七章编程练习6-10
- C++Primer Plus(第六版)第七章编程练习
- C++ PRIMER PLUS (第六版) 中文版 第七章编程练习答案
- C++ primer Plus(第六版)_课后编程练习_第七章
- C++ primer Plus(第六版)中文版 第七章 函数——C++的编程模块 编程练习答案
- C++ Primer Plus第六版 第七章 编程练习答案
- C primer plus 第六版 第七章 编程练习 答案
- C++ Primer Plus 第六版 学习笔记 第七章 编程练习答案
- C++ Primer Plus(第六版) 第二章 编程练习
- C++primer plus第六版课后编程练习答案2.6
- C++primer plus第六版课后编程练习答案4.6
- C++primer plus第六版课后编程练习答案7.5
- C++primer plus第六版课后编程练习答案9.1
- C++primer plus第六版课后编程练习答案10.2
- C++primer plus第六版课后编程练习答案11.5和11.6