i am new to c programming and i wanna ask for help.
at the end of the coding part, how can i print out the orderlist, the quantity and the total price for the food? I personally think that it is similar as print out a reciept but i have no idea how to do it.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <ctype.h>
#include <math.h>
#include <string.h>
#include <conio.h>
void menu();
float Bfast();
float Lunch();
float Dinner();
float Bvrg();
float total();
void displaybreakfast(){
printf("\n\n\t[A] A COURSE: Chinese DimSum (SiuMaai, HaGaau, CheungFan, Juk(each come with 3 sets))----RM33.99");
printf("\n\t[B] B COURSE: Nasi Lemak (Coconut Rice, Anchovies, Hot Sauce, Peanuts, and Boiled Egg)----RM30.99" );
printf("\n\t[C] C COURSE: Full English Breakfast (Eggs, Toast, Bacon and Sausage, Pancakes, Home Fries)----RM35.99");
}
void displaylunch(){
printf("\n\n\t[D] A COURSE: Pan-Seared Ora King Salmon (with French Onion Soup and Salted Caramel Creme Brulee)----RM61.99");
printf("\n\t[E] B COURSE: Zucchini and Squash, Spaghetti Style (with Lobster Bisque and Salted Caramel Creme Brulee)----RM56.99");
printf("\n\t[F] C COURSE: 5oz Fillet Mignon and Lobster Tail (with Caesar Salad and Salted Caramel Creme Brulee)----RM68.99");
}
void displaydinner(){
printf("\n\n\t[G] A COURSE: A5 3oz Japanese Wagyu New York Strip (with Foie Gras and Caviar as topping)----RM140.99");
printf("\n\t[H] B COURSE: Shellfish Tower (with Classic Shrimp Cocktail, Lobster Tail, Oysters, Snow Crab)----RM 127.99");
printf("\n\t[I] C COURSE: Rosen Farms Colorado Lamb Chop [used Mint Gel, Horseradish, Natural Jus]----RM122.99");
}
void displaybeverage(){
printf("\n\n\t[J]Distilled Sky Juice(glass)----RM5.00");
printf("\n\t[K]Chinese Tea Da Hong Pao(jug)----RM15.00");
printf("\n\t[L]80s Red Wine(bottle)----RM100.00");
}
void displayexit(){
printf("\n\t\t\tThank You. Have A Nice Day.\n");
printf("\n\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
printf("\n\t\t\tHope To See U Again.");
}
int x, k, paymethod;
char course;
int z;
float land, buff, pro, dess, totald, total1, total2, total3, total4;
int main(){
time_t t;
time(&t);
printf("\n\n\n\n\t\t\t\t\t%s", ctime(&t));
printf("\n\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
printf("\n\t\t\t\tWelcome to Blue Cap De Moivre's Culinary");
printf("\n\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
menu();
return 0;
}
void menu(){
int x;
printf("\n\t\t[1] BREAKFAST(0700~~~1030)\n\t\t[2] LUNCH(1230~~~1600)\n\t\t[3] DINNER(1800~~~2130)\n\n");
printf("Please Select Your Option Above. ");
scanf("%d",&x);
switch(x){
case 1: Bfast();
break;
case 2: Lunch();
break;
case 3: Dinner();
break;
default:
printf("Invalid Error!\n");
main();
}
}
float Bfast(){
system("cls");
printf("\n\nYou have selected Breakfast Menu.");
displaybreakfast();
printf("\n\nPlease select course. \n");
scanf("%c", &course);
scanf("%c", &course);
if(course=='A' || course=='a'){
printf("\n\nPlease enter the quantity. ");
scanf("%d", &x);
land=33.99*x;
printf("\n\nYou have ordered %d A COURSE: Chinese DimSum.", x);
}
else if(course=='B' || course=='b'){
printf("\n\nPlease enter the quantity. ");
scanf("%d", &x);
land=30.99*x;
printf("\n\nYou have ordered %d B COURSE: Nasi Lemak.", x);
}
else if(course=='C' || course=='c'){
printf("\n\nPlease enter the quantity. ");
scanf("%d", &x);
land=35.99*x;
printf("\n\nYou have ordered %d C COURSE: Full English Breakfast", x);
}
else{
printf("\n\nYou have press wrong button.");
menu();
}
Bvrg();
return x;
}
float Lunch(){
system("cls");
printf("\n\nYou have selected Lunch Menu.");
displaylunch();
printf("\n\nPlease select course.");
scanf("%c", &course);
scanf("%c", &course);
if(course=='D' || course=='d'){
printf("\n\nPlease enter the quantity.");
scanf("%d", &x);
buff=61.99*x;
printf("\n\nYou have ordered %d A COURSE: Pan-Seared Ora King Salmon.", x);
}
else if(course=='E' || course=='e'){
printf("\n\nPlease enter the quantity.");
scanf("%d", &x);
buff=56.99*x;
printf("\n\nYou have ordered %d B COURSE: Zucchini and Squash, Spaghetti Style.", x);
}
else if(course=='F' || course=='f'){
printf("\n\nPlease enter the quantity.");
scanf("%d", &x);
buff=68.99*x;
printf("\n\nYou have ordered %d C COURSE: 5oz Fillet Mignon and Lobster Tail.", x);
}
else{
printf("\n\nYou have press wrong button.");
menu();
}
Bvrg();
return x;
}
float Dinner(){
system("cls");
printf("\n\nYou have selected Dinner Menu.");
displaydinner();
printf("\n\nPlease select course.");
scanf("%c", &course);
scanf("%c", &course);
if(course=='G' || course=='g'){
printf("\n\nPlease enter the quantity.");
scanf("%d", &x);
pro=140.99*x;
printf("\n\nYou have ordered %d A COURSE: A5 3oz Japanese Wagyu New York Strip.", x);
}
else if(course=='H' || course=='h'){
printf("\n\nPlease enter the quantity.");
scanf("%d", &x);
pro=127.99*x;
printf("\n\nYou have ordered %d B COURSE: Shellfish Tower.", x);
}
else if(course=='I' || course=='i'){
printf("\n\nPlease enter the quantity.");
scanf("%d", &x);
pro=122.99*x;
printf("\n\nYou have ordered %d C COURSE: Rosen Farms Colorado Lamb Chop.", x);
}
else{
printf("\n\nYou have press wrong button.");
menu();
}
Bvrg();
return x;
}
float Bvrg(){
system("cls");
printf("\n\nYou have entered Beverage Menu.");
displaybeverage();
printf("\n\nPlease select your drink.");
scanf("%c", &course);
scanf("%c", &course);
if(course=='J' || course=='j'){
printf("\n\nPlease enter the quantity.");
scanf("%d", &x);
dess=5.00*x;
printf("\n\nYou have ordered %d Distilled Sky Juice.", x);
}
else if(course=='K' || course=='k'){
printf("\n\nPlease enter the quantity.");
scanf("%d", &x);
dess=15.00*x;
printf("\n\nYou have ordered %d Chinese Tea Da Hong Pao.", x);
}
else if(course=='L' || course=='l'){
printf("\n\nPlease enter the quantity.");
scanf("%d", &x);
dess=100.00*x;
printf("\n\nYou have ordered %d 80s Red Wine.", x);
}
else{
printf("\n\nYou have press wrong button.");
displayexit();
}
printf("\n\nDo you want to add-on?(1-Yes, 2-No)");
scanf("%d",&z);
if(z == 1){
system("cls");
total1=land;
total2=buff;
total3=pro;
total4=dess;
menu();
}
else{
total1=0;
total();
}
return x;
}
float total(){
printf("\n\nThe menu ordered are:");
totald+=total1+total2+total3+total4;
printf("\n\nThe total price are: RM%.2f", totald);
printf("\n\n(1)Pay by cash or (2)Pay by card.");
scanf("%d", &paymethod);
displayexit();
return 0;
}