Hi Sir/Madam,
Need your help again, i failed to do output display for the menu list from this code. Suppose the output have to come out with menu = item selected, tax and amount of item.
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
double price[8] = {2.50 , 3.45, 2.20 , 2.95 , 3.45 , 0.70 , 1.50 , 1.80};
double mealTaxPrices[9];
int menuList,menuPrices;
void printMeals();
void orderMeals();
double order();
int main()
{
char response = 'y';
printMeals();
while(response == 'y'|| response == 'Y')
{
orderMeals();
printf("\nwould you like to continue(y/n):");
scanf(" %c",&response);
}
printf("\n ******************** THANK YOU FOR COMING *************************\n");
printf("\20********************** PLEASE VISIT US NEXT TIME **************************\20 \n");
system("pause");
return 0;
}
void printMeals()
{
printf(" \t\t\t WELCOME TO HiFi's RESTURANT \n");
printf(" \t\t\t \n");
printf(" \t\t\t MEALS\t\t\tPRICE:\n");
printf(" \t\t\t \22*******************************\22\n");
printf(" \t\t\t 1- Plain Egg\t\t$2.50\n");
printf(" \t\t\t 2- Bacon and Egg\t$3.45\n");
printf(" \t\t\t 3- Muffin\t\t$2.20\n");
printf(" \t\t\t 4- French Toast\t$2.95\n");
printf(" \t\t\t 5- Fruit Basket\t$3.45\n");
printf(" \t\t\t 6- Cereal\t\t$0.70\n");
printf(" \t\t\t 7- Coffee\t\t$1.50\n");
printf(" \t\t\t 8- Tea\t\t\t$1.80\n");
printf("\n");
}
void orderMeals()
{
double totalPrice;
double allPayment;
// double tax, taxAmount;
// double menuList, totalAllManu;
totalPrice = order();
// tax= taxAmount;
// menuList = totalAllManu;
allPayment =totalPrice;
// printf(" \t\t\tMenu List: \t\t\t%5.2f\n",menuList);
// printf(" \t\t\tTax: 5%% \t\t\t%5.2f\n",tax);
printf(" \t\t\tTotal Amount: \t\t\t%5.2f\n",allPayment);
}
double order()
{
int menuOption,i,amount;
char response = 'y';
double total = 0.0,totalAllMenu = 0.0;
double tax = 5.0;
while(response == 'y' || response == 'Y')
{
printf("please choose your Meal(s): ");
scanf("%d",&menuOption);
printf("please enter your amount:");
scanf("%d",&amount);
if(menuOption<1 || menuOption>7)
{
printf("sorry we don`t have this order \nagain! ");
continue;
}
if (menuOption==1)
{
printf("%d Plain Egg %8.2f",amount,(amount * price[menuOption - 1] ));
}
if (menuOption==2)
{
printf("%d Bacon and Egg %8.2f",amount,(amount * price[menuOption - 1] ));
}
if (menuOption==3)
{
printf("%d Muffin %8.2f",amount,(amount * price[menuOption - 1] ));
}
if (menuOption==4)
{
printf("%d French Toast %8.2f",amount,(amount * price[menuOption - 1] ));
}
if (menuOption==5)
{
printf("%d Fruit Basket %8.2f",amount,(amount * price[menuOption - 1] ));
}
if (menuOption==6)
{
printf("%d Cereal %8.2f",amount,(amount * price[menuOption - 1] ));
}
if (menuOption==7)
{
printf("%d Coffee %8.2f",amount,(amount * price[menuOption - 1] ));
}
if (menuOption==8)
{
printf("%d Tea %8.2f",amount,(amount * price[menuOption - 1] ));
}
total += (amount * price[menuOption - 1] );
printf("\nWould you like to enter more orders(y/n):");
scanf(" %c",&response);
}
printf("\n");
response = 'y';
return total += total * tax / 100;
}