1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
float getPrice(char valueMeal)
{
float price = 0;
switch(valueMeal)
{
case 'a':
case 'A':
price = 45;
break;
case 'b':
case 'B':
price = 50;
break;
case 'c':
case 'C':
price = 55;
break;
case 'd':
case 'D':
price = 60;
break;
case 'e':
case 'E':
price = 75;
break;
default: price=0;
}
return price;
}
int main()
{
float numOfOrder1,
numOfOrder2,
numOfOrder3,
numOfOrder4,
subTotal1,
subTotal2,
subTotal3,
subTotal4,
subTotal5,
valueMeal,
totalAmount;
char orderType1,
orderType2,
orderType3,
orderType4,
orderType5;
scanf( "%c %f\n\n", &orderType1, &numOfOrder1);
scanf( "%c %f\n\n", &orderType2, &numOfOrder2);
scanf( "%c %f\n\n", &orderType3, &numOfOrder3);
scanf( "%c %f\n\n", &orderType4, &numOfOrder4);
valueMeal = getPrice(orderType1);
subTotal1 = valueMeal * numOfOrder1;
printf("Subtotal Is : %f \n", subTotal1);
valueMeal = getPrice(orderType2);
subTotal2 = valueMeal * numOfOrder2;
printf("Subtotal Is : %f \n", subTotal2);
valueMeal = getPrice(orderType3);
subTotal3 = valueMeal * numOfOrder3;
printf("Subtotal Is : %f \n", subTotal3);
valueMeal = getPrice(orderType4);
subTotal4 = valueMeal * numOfOrder4;
printf("Subtotal Is : %f \n", subTotal4);
totalAmount = subTotal1 + subTotal2 + subTotal3 + subTotal4;
printf("Total Amount Is:");
printf("%0.f ",totalAmount);
system("pause");
return 0;
}
|