4
493245744
#include<stdio.h>
main()
{
int salenumber,quantity;
int quantity1=0,quantity2=0,quantity3=0,quantity4=0,quantity5=0;
double price1,price2,price3,price4,price5;
printf("enter the salenumber and the quantity\n");
while((salenumber=getchar())!=EOF)
{
scanf("%d",&quantity);
switch(salenumber){
case 1:
quantity1+=quantity;
break;
case 2:
quantity2+=quantity;
break;
case 3:
quantity3+=quantity;
break;
case 4:
quantity4+=quantity;
break;
case 5:
quantity5+=quantity;
break;
case '\n':
case '\t':
case ' ' :
break;
default:
printf("enter a worry salenumber.");
printf("enter a new salenumber\n");
}
}
price1=2.98*quantity1;
price2=4.50*quantity2;
price3=9.98*quantity3;
price4=4.49*quantity4;
price5=6.87*quantity5;
printf("price1=%f,price2=%f,price3=%f,price4=%f,price5=
%f",price1,price2,
price3,price4,price5
);
system("pause");
return 0;
}
main()
{
int salenumber,quantity;
int quantity1=0,quantity2=0,quantity3=0,quantity4=0,quantity5=0;
double price1,price2,price3,price4,price5;
printf("enter the salenumber and the quantity\n");
while((salenumber=getchar())!=EOF)
{
scanf("%d",&quantity);
switch(salenumber){
case 1:
quantity1+=quantity;
break;
case 2:
quantity2+=quantity;
break;
case 3:
quantity3+=quantity;
break;
case 4:
quantity4+=quantity;
break;
case 5:
quantity5+=quantity;
break;
case '\n':
case '\t':
case ' ' :
break;
default:
printf("enter a worry salenumber.");
printf("enter a new salenumber\n");
}
}
price1=2.98*quantity1;
price2=4.50*quantity2;
price3=9.98*quantity3;
price4=4.49*quantity4;
price5=6.87*quantity5;
printf("price1=%f,price2=%f,price3=%f,price4=%f,price5=
%f",price1,price2,
price3,price4,price5
);
system("pause");
return 0;
}