Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

//Header Files

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <windows.h>

//Function Prototypes
void m_m();

//Global Variable
int num;
float price;
float total;
char choice;
int again;
char items[3][50] = {"Coffee", "Egg Muffin", "Kebap"};
float itemsPrice[3] = {1.00, 1.50, 2.00};
int itemsQuantity[3] = {0,0,0};

i=0; //infinite loop

void main(){
m_m();
}

void m_m() // main menu screen


{
char choice = ' ' ; //local variable

printf(" Welcome to ABC Cafe. \n ");


printf(" +============================+ \n\n");
printf(" && Please select an option. && \n\n");
printf("\t\t [A] View our Menu\n");
printf("\t\t [B] Exit\n\n");
printf("Enter your choice here : ");
scanf("%c", &choice);
system("cls");

if (toupper(choice) == 'A' )
menu();
else if (toupper(choice) == 'B');
else if (toupper(choice) != 'A' , 'B')
m_m();
}

void menu(clear) //Menu Screen


{
//Local Variables
int choice = 0;
int again = 0;
int quantity;

if(clear)
fflush(stdin);
printf(" Welcome to ABC Cafe. \n ");
printf(" +============================+ \n\n");
printf(" $ Menu $ \n\n");
printf(" && Please select the food that you would like to purchase. && \n\n");
printf("\t\t [1] Coffee - 1.00TL\n");
printf("\t\t [2] Egg Muffin - 1.50TL\n");
printf("\t\t [3] Kebap - 2.00TL\n");

printf("Enter your choice here : ");


scanf("%d", &choice);

if (choice == 1){
printf("Enter quantity : ");
scanf("%d", &quantity);
itemsQuantity[0] = quantity;
total += itemsPrice[0] * itemsQuantity[0];
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : "); //
Allows user to choose whether to check-out or buy anything else.
scanf("%d", &again);
system("cls");

if (again == 1 )
menu();
else if (again == 2 ){
fflush(stdin);
printf("Your total amount is %.2fTL , Please pay at the counter\n\n\n
", total);
exitScript();
}
else
printf("\n\n\t\tSorry Invalid Decision Entered\n\n\n\n");
}
else if ( choice == 2){
printf("Enter quantity : ");
scanf("%d", &quantity);
itemsQuantity[1] = quantity;
total += itemsPrice[1] * itemsQuantity[1];
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : "); //
Allows user to choose whether to check-out or buy anything else.
scanf("%d", &again);
system("cls");

if (again == 1 )
menu();
else if (again == 2 ){
fflush(stdin);
printf("Your total amount is %.2fTL , Please pay at the counter\n\n\n
", total);
exitScript();
}
else
printf("\n\n\t\tSorry Invalid Decision Entered\n\n\n\n");
}
else if ( choice == 3 ){
printf("Enter quantity : ");
scanf("%d", &quantity);
itemsQuantity[2] = quantity;
total += itemsPrice[2] * itemsQuantity[2];
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : "); //
Allows user to choose whether to check-out or buy anything else.
scanf("%d", &again);
system("cls");

if (again == 1 )
menu();
else if (again == 2 ){
fflush(stdin);
printf("Your total amount is %.2fTL , Please pay at the counter\n\n\n
", total);
exitScript();
}
else
printf("\n\n\t\tSorry Invalid Decision Entered\n\n\n\n");
}
else{
fflush(stdin);
system("cls");
printf("\n\n\t\t Invalid Choice Entered\n\n");
menu();
}
}

void exitScript(){
int stuff = 0;
printf(" Thank You Very Much \n ");
printf(" +============================+ \n\n");
printf(" && Please come again. && \n\n");
exit(0);
}

You might also like