回复 7楼 Devon_Ye
完全看不懂哦
我改了我的能运行了
#include <stdio.h>
main ()
{
int model=0;
double sale1=0, sale2=0,
sale3=0, sale4=0, sale5=0, sum=0;
double model1=2.98, model2=4.50, model3=9.98,
model4=4.49, model5=6.87;
while (1)
{
printf ("Enter the model of the product");
scanf ("%d", &model);
if (model==-1)
break;
switch (model)
{
case 1 :
++sale1;
break;
case 2 :
++sale2;
break;
case 3 :
++sale3;
break;
case 4 :
++sale4;
break;
case 5 :
++sale5;
break;
case '\n' : case ' ' :
break;
default :
printf ("Incorrect model entered.");
printf ("Enter a new model.\n");
break;
}
}
sum=model1*sale1+model2*sale2+model3*sale3+model4*sale4+model5*sale5;
printf ("The total sales if the product is %.2f\n", sum);
return 0;
}