#include<stdio.h> #include<string.h> #include<ctype.h> #include<stdlib.h>
typedef struct{ char menuitem[20]; float price; }ITEMTYPE;
void MENU(int no,char fudz,float prc) { printf("\n01 fried_egg
$1.45\n"); printf("02 bacon_&_egg 2.45\n");
printf("03 muffin 0.99\n");
printf("04 french_toast 1.99\n");
printf("05 fruit_basket 2.49\n");
}
main() {
/*variables*/
ITEMTYPE ai[20];
FILE *optr;
int choice,no,i,count=0;
char fudz;
float total,prc,tprice=0;
/*pointing to bill.c*/
optr=fopen("bill.c","w+");
printf("WELCOME TO WALING-WALING's RESTAURANT!!!\n\n");
printf("please select from our Menu..\n\n");
/*call fnc MENU*/
MENU(no,fudz,prc);
printf("\n\nPLEASE ENTER THE NUMBER OF YOUR CHOICE,\n0 to exit\n\n");
fprintf(optr," ========================================= \n");
fprintf(optr," OFFICIAL RECEIPT \n");
fprintf(optr," ========================================= \n");
fprintf(optr," ITEMS PRICE \n\n");
for(count=0;choice!=0;count++)
{
printf("CHOICE: ");
scanf("%i",&choice);
if(choice==1)
{
fprintf(optr," fried egg $1.45 \n");
tprice=(tprice+1.45);
}
else if(choice==2)
{
fprintf(optr," bacon & egg $2.45 \n");
tprice=tprice+2.45;
}
else if(choice==3)
{
fprintf(optr," muffin $0.99 \n");
tprice=tprice+0.99;
}
else if(choice==4)
{
fprintf(optr," french toast $1.99 \n");
tprice=tprice+1.99;
}
else if(choice==5)
{
fprintf(optr," fruit basket $2.49 \n");
tprice=tprice+2.49;
}
else if(choice==0)
{
{
system("clear");
printf("\n\n\nYOUR ORDER IS BEING PROCESSED...\n");
printf("\n\nPLEASE CHECK ee bill.c FOR YOUR
RECIEPT.\nTHANK YOU, PLEASE COME AGAIN!!\n\n");
}
}
float VAT;
VAT=tprice*.05;
fprintf(optr,"\n\n\n*******TOTAL: %.2f\n",tprice);
fprintf(optr,"*******VAT:
%.2f\n",VAT);
fprintf(optr,"*******TOTAL BILL:
%.2f\n\n\n",VAT+tprice);
fprintf(optr," WALING-WALING's
RESTAURANT\n");
fprintf(optr," Thank You!! Please Come
Again!!\n\n");
}
My professor said that the output of this program I made was not the one he's
looking for...
The program should give an output in which it should have a function printCheck
that will calculate and print the check directly. What I did here was the check
will be opened in another file. What should I do? Plus, how will open a file
that will display the menu? Can somebody please help me?