实验二4
#include "stdafx.h" int main(int argc, char* argv[]) { double a,rate,tax,profit; scanf("%lf",&a); if(a<500) { rate=0.00; tax=rate*a; profit=a-tax; printf("%lf\n%lf\n%lf\n",rate,tax,profit); } else if(a>=500&&a<1000) { rate=0.05; tax=rate*a; profit=a-tax; printf("%lf\n%lf\n%lf\n",rate,tax,profit); } else if(a>=2000&&a<5000) { rate=0.08; tax=rate*a; profit=a-tax; printf("%lf\n%lf\n%lf\n",rate,tax,profit); } else { rate=0.15; tax=rate*a; profit=a-tax; printf("%lf\n%lf\n%lf\n",rate,tax,profit); } return 0; }
#include<stdafx.h> int main() { double a,rate,profit,tax; scanf("%lf",&a); int c; c=a/500; switch(c) { case 0:rate=0.00;break; case 1:rate=0.05;break; case 2:rate=0.08;break; case 3:rate=0.08;break; case 4:rate=0.10;break; case 5:rate=0.10;break; case 6:rate=0.10;break; case 7:rate=0.10;break; case 8:rate=0.10;break; case 9:rate=0.10;break; case 10:rate=0.15;break; } tax=a*rate; profit=a-tax; printf("a=%lf,rate=%lf,tax=%lf,profit=%lf",a,rate,tax,profit); return 0; }