Modify the program to take orders repeatedly and to calculate the correct change for each order.
Add a facility for cancelling the whole order and starting from scratch.
Add a facility for cancelling an item: use lower-case letters for entering items and upper-case letters for cancelling them. Do not forget to display an error message when there is an attempt to cancel an item that has not been entered (or, say, when an item that has only been requested twice is cancelled three times). Display an itemised receipt for each order.
#include<stdio.h>
#define BIG 2.50 /*price of big duck */
#define HAM 2.00 /*price of hamburger */
#define CHE 2.00 /* price of cheeseburger */
#define FRI 0.50 /*price of frise */
#define LAR 0.75 /*price of large frise */
#define SOF 0.50 /*price of soft drink*/
#define APP 1.00 /*price of apple pie*/
#define MIL 0.75 /*price of milk shake */
int main()
{
char key;
/*key pressed*/
int items=0; /*number
of food items */
int done =0; /*order
complete? */
float total = 0.00; /*total
price*/
for(;;)
{
/* output information: */
puts("McDUCK'S ELECTRONIC MENU SYSTEM");
puts("===============================\n");
puts("Smile at customer; \"How may I help
you?\"\n");
puts(" [B]ig Duck
-press B (then Enter)");
puts(" [H]amburger
-press H (then Enter)");
puts(" [C]heesburger -press C
(then Enter)");
puts(" [F]rise
-press F (then
Enter)");
puts(" [L]large frise -press L
(then Enter)");
puts(" [S]oft drink -press S
(then Enter)");
puts(" [A]pple pie
-press A (then Enter)");
puts(" [M]ilk shake -press M
(then Enter)");
puts("press [X] (then Enter) when order is
complete\n");
/*Hanle key presses: */
do{
key= getchar(); /*read
key */
if (key=='\n') key =
getchar(); /*ignore new-line characters*/
switch (key)
{
case 'B': case
'b':
printf(" Big
Duck $%4.2f\n",BIG);
items++;
total+=BIG;
break;
case 'H':case
'h':
printf("Hamburger
$%4.2f\n",HAM);
items++;
total+= HAM;
break;
case 'C': case
'c':
printf("Cheesburger
$%4.2f\n",CHE);
items++;
total+=CHE;
break;
case 'F': case
'f':
printf("
Frise $%4.2f\n",FRI);
items++;
total+=FRI;
break;
case 'L': case
'l':
printf(" Larger frise $%4.2f\n",LAR);
items++;
total+=LAR;
break;
case 'S':
case's':
printf("Soft
drink $%4.2f\n",SOF);
items++;
total+=SOF;
break;
case 'A': case
'a':
printf("Apple
pie $%4.2f\n",APP);
items++;
total+=APP;
break;
case 'M': case
'm':
printf(" Milk
shake $%4.2f\n",MIL);
items++;
total+=MIL;
break;
case 'X': case
'x':
printf("\nOrder
complete - ");
printf("%d items
- total $%4.2f\n",items,total);
done=1;
break;
defult :
puts(" Invalid key! Try again.");
break;
}
}while(done<1);
/* Output information: */
puts("\"Thanks for eating at McDuck's! Enjoy your
meal!\"");
}
}
/*C-program to Get, Modify or cancle orders from McDUCK*/
#include<stdio.h>
#include<stdlib.h>
#define BIG 2.50 /*price of big duck */
#define HAM 2.00 /*price of hamburger */
#define CHE 2.00 /* price of cheeseburger */
#define FRI 0.50 /*price of frise */
#define LAR 0.75 /*price of large frise */
#define SOF 0.50 /*price of soft drink*/
#define APP 1.00 /*price of apple pie*/
#define MIL 0.75 /*price of milk shake */
int main()
{
char key; /*key pressed*/
int items=0; /*number of food items */
int done =0; /*order complete? */
float total = 0.00; /*total price*/
/* For taking count of each item that order
*/
int Bcount = 0, Hcount = 0, Ccount = 0, Fcount = 0,
Lcount = 0, Scount = 0, Acount = 0, Mcount = 0;
//This gives us facility to take orders
repeatedly
for(;;)
{
/* Reinitializes all values For
next order */
items=0;done =0;total = 0.00;
Bcount = 0; Hcount = 0; Ccount = 0;
Fcount = 0; Lcount = 0; Scount = 0; Acount = 0; Mcount = 0;
/* output information: */
/* We modify input add facility for
cancle item and order item also for
Taking order from scrach we get
extra input as Z/z it means it cancle whole
previous order and start from the
scrach*/
puts("McDUCK'S ELECTRONIC MENU
SYSTEM");
puts("===============================\n");
puts("Smile at customer; \"How
may I help you?\"\n");
puts(" [B]ig Duck -press b (order
item) press B (cancle item) (then Enter)");
puts(" [H]amburger -press h (order
item) press H (cancle item) (then Enter)");
puts(" [C]heesburger -press c
(order item) press C (cancle item) (then Enter)");
puts(" [F]rise -press f (order
item) press F (cancle item) (then Enter)");
puts(" [L]large frise -press l
(order item) press L (cancle item) (then Enter)");
puts(" [S]oft drink -press s (order
item) press S (cancle item) (then Enter)");
puts(" [A]pple pie -press a (order
item) press A (cancle item) (then Enter)");
puts(" [M]ilk shake -press m (order
item) press M (cancle item) (then Enter)\n");
puts("press [Z] (then Enter) when
wants to order from scrach");
puts("press [X] (then Enter) when
order is complete\n");
puts("press [0] (then Enter) for
exit\n");
/*Hanle key presses: */
do{
key= getchar();
/*read key */
if (key=='\n')
key = getchar(); /*ignore new-line characters*/
/* It checks
for uppercase letters only*/
if(key >= 65
&& key <= 90 || key == 'x'){
switch (key)
{
/* For each item it takes order and increse count, total and order
*/
case 'B':
printf("
Big Duck $%4.2f\n",BIG);
items++;
Bcount++;
total+=BIG;
break;
case 'H':
printf("Hamburger $%4.2f\n",HAM);
items++;
Hcount++;
total+=
HAM;
break;
case 'C':
printf("Cheesburger $%4.2f\n",CHE);
items++;
Ccount++;
total+=CHE;
break;
case 'F': case 'f':
printf("
Frise $%4.2f\n",FRI);
items++;
Fcount++;
total+=FRI;
break;
case 'L':
printf("
Larger frise $%4.2f\n",LAR);
items++;
Lcount++;
total+=LAR;
break;
case 'S':
printf("Soft drink $%4.2f\n",SOF);
items++;
Scount++;
total+=SOF;
break;
case 'A':
printf("Apple pie $%4.2f\n",APP);
items++;
Acount++;
total+=APP;
break;
case 'M':
printf("
Milk shake $%4.2f\n",MIL);
items++;
Mcount++;
total+=MIL;
break;
case 'Z':
printf("\nOrder Discarded \n");
done=1;
// It
clears console screen
system("clear");
break;
case 'X': case 'x':
printf("\nOrder complete - \n");
/*
Itemised output for each item with price */
if(Bcount
> 0){
printf(" Big Duck %d times worth value
$%4.2f\n",Bcount,BIG * Bcount);
}
if(Hcount
> 0){
printf(" Hamburger %d times worth value
$%4.2f\n",Hcount,HAM * Hcount);
}
if(Ccount
> 0){
printf(" Cheesburger %d times worth value
$%4.2f\n",Ccount,CHE * Ccount);
}
if(Fcount
> 0){
printf(" Frise %d times worth value
$%4.2f\n",Fcount,FRI * Fcount);
}
if(Lcount
> 0){
printf(" Larger frise %d times worth value
$%4.2f\n",Lcount,LAR * Lcount);
}
if(Scount
> 0){
printf(" Soft drink %d times worth value
$%4.2f\n",Scount,SOF * Scount);
}
if(Acount
> 0){
printf(" Apple pie %d times worth value
$%4.2f\n",Acount,APP * Acount);
}
if(Mcount
> 0){
printf(" Milk shake %d times worth value
$%4.2f\n",Mcount,MIL * Mcount);
}
printf("%d
items - total $%4.2f\n",items,total);
done=1;
/* Output
information: */
puts("\"Thanks for eating at McDuck's! Enjoy your
meal!\n\n\"");
break;
default :
puts("
Invalid order item! Try again.");
break;
}
}
else
if(key >= 97 && key <= 122)
/* It checks for lowercase
letters only*/
switch (key)
{
/* For each case its checks for item count and then cancle or
gives error*/
case
'b':
if(Bcount > 0){
printf(" Big Duck
$%4.2f Cancled\n",BIG);
items--;
Bcount--;
total-=BIG;
}else{
puts(" Invalid cancle item!
Your order for this item is less");
}
break;
case
'h':
if(Hcount > 0){
printf(" Hamburger
$%4.2f Cancled\n",HAM);
items--;
Hcount--;
total-= HAM;
}else{
puts(" Invalid cancle item!
Your order for this item is less");
}
break;
case
'c':
if(Ccount > 0){
printf(" Cheesburger
$%4.2f Cancled\n",CHE);
items--;
Ccount--;
total-=CHE;
}else{
puts(" Invalid cancle item!
Your order for this item is less");
}
break;
case
'f':
if(Fcount > 0){
printf(" Frise
$%4.2f Cancled\n",FRI);
items--;
Fcount--;
total-=FRI;
}else{
puts(" Invalid cancle item!
Your order for this item is less");
}
break;
case
'l':
if(Lcount > 0){
printf(" Larger frise
$%4.2f Cancled\n",LAR);
items--;
Lcount--;
total-=LAR;
}else{
puts(" Invalid cancle item!
Your order for this item is less");
}
break;
case's':
if(Scount > 0){
printf(" Soft drink
$%4.2f Cancled\n",SOF);
items--;
Scount--;
total-=SOF;
}else{
puts(" Invalid cancle item!
Your order for this item is less");
}
break;
case
'a':
if(Acount > 0){
printf(" Apple pie
$%4.2f Cancled\n",APP);
items--;
Acount--;
total-=APP;
}else{
puts(" Invalid cancle item!
Your order for this item is less");
}
break;
case
'm':
if(Mcount > 0){
printf(" Milk shake
$%4.2f Cancled\n",MIL);
items--;
Mcount--;
total-=MIL;
}else{
puts(" Invalid cancle item!
Your order for this item is less");
}
break;
case
'z':
printf("\nOrder Discarded ");
done=1;
// It clears console screen
system("clear");
break;
default
:
puts(" Invalid item! Not included in order
list,Try again.");
break;
}
/* If user
enters any other character */
else{
if(key == 0)
exit(0);
puts(" Invalid key! Try
again.");
}
}while(done<1);
}
}










Modify the program to take orders repeatedly and to calculate the correct change for each order....