How to call items to print receipt
Hi, I dont know how to do this part and according to all posts and codes I read, the code does not store how many I've ordered, and it just shows the total price.
The end goal is to be able to print the individual orders, quantity, and price then its total.
It would look like this:
Order Quantity Price
Breakfast Burrito 2 460
Blueberry Pancakes 1 180
Total 640
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
//void (for menu) declarations
void Menu (void);
void Options (void);
void TakeOrder (void);
void OptionsGoingToReceipt (void);
void Receipt (void);
int trial;
int OptionCode, MenuCode;
int OptionReceipt;
//declaration for quantity
int quantity;
//declaration for price
float price;
float TotalPrice;
float SubTotal;
//main program
int main ()
{
//username+password
char username[20];
char password[20];
InputUsernamePasswordAgain: //for goto
printf("\n*************************************");
printf("\nEnter your username: ");
scanf("%s",username);
printf("***********************************");
printf("\nEnter your password: ");
scanf("%s",password);
if( strcmp ( username,"yeeted" ) == 0 && strcmp ( password,"animo" ) == 0 )
{
printf("***********************************");
printf("\nWelcome back! You are now logged in! ");
printf("\n*************************************");
printf("\n\n----------------------------------------------------------------------------------------");
printf ("\n Welcome to Sunny Breakfast Hub!");
printf ("\n Established 2020");
printf("\n----------------------------------------------------------------------------------------");
Menu ();
Options ();
}
else if( strcmp( username,"deleted") == 0 && strcmp ( password,"animo") == 0 )
{
printf("***********************************");
printf("\nWelcome back! You are now logged in! ");
printf("\n*************************************");
printf("\n\n----------------------------------------------------------------------------------------");
printf ("\n Welcome to Sunny Breakfast Hub!");
printf ("\n Established 2020");
printf("\n----------------------------------------------------------------------------------------");
Menu ();
Options ();
}
else if( strcmp (username,"dlsu") == 0 && strcmp (password,"animo") == 0)
{
printf("***********************************");
printf("\nWelcome back! You are now logged in! ");
printf("\n*************************************");
printf("\n\n----------------------------------------------------------------------------------------");
printf ("\n Welcome to Sunny Breakfast Hub!");
printf ("\n Established 2020");
printf("\n----------------------------------------------------------------------------------------");
Menu ();
Options ();
}
else
{
printf("***********************************");
printf("\nUsername or Password is incorrect!");
printf("\nPlease try again! ");
goto InputUsernamePasswordAgain;
}
}
//void function for MENU
void Menu (void)
{
printf("\n\n========================================================================================");
printf ("\n\t SUNNY BREAKFAST HUB MENU");
printf("\n========================================================================================");
printf
("\n\n ~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~");
printf
("\n SUNNY BREAKFAST COMBOS ALL DAY SANDWICH");
printf
("\n ~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~");
printf
("\n\n101 Chicken 'n Waffles P280 201 Honey Glazed Ham P200");
printf
("\n102 Breakfast Burrito P230 202 Tuna Mayo P200");
printf
("\n103 All American Platter P400 203 Chicken 'n Cheese P180");
printf
("\n104 Bacon Maniac w/ Eggs P300 204 Steak 'n Cheese P250");
printf
("\n105 Classic Eggs Benedict P250 205 Vegan Delight P150");
printf ("\n106 Sausage Maniac w/ Eggs P300");
printf ("\n107 Fiesta Omelette P250");
printf
("\n\n ~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
printf
("\n GOOD MORNING PANCAKES SUNNY COFFEE AND REFRESHMENTS");
printf
("\n ~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
printf
("\n\n301 Mixed Berries P180 401 Vanilla Milkshake P120");
printf
("\n302 Blueberry P180 402 Cappucino P120");
printf
("\n303 Chocolate Chip P150 403 Mocha Frappucino P100");
printf
("\n304 Banana Walnut P150 404 Fresh Orange Juice P80");
}
//void function for OPTIONS
void Options (void)
{
do
{
printf("\n\n========================================================================================");
printf ("\n\t SUNNY BREAKFAST HUB OPTIONS");
printf("\n========================================================================================");
printf ("\n\n01 Back to Menu ");
printf ("\n02 Take Order");
printf ("\n03 Exit Program");
printf ("\n\nEnter the Option Code here: ");
scanf ("%i", &OptionCode);
//while code (if option code is not in between 1-3)
while (OptionCode < 01 || OptionCode > 03)
{
printf("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
printf("\n *** Oops! The Option Code entered is not in the choices. Please try again: ");
scanf ("%i", &OptionCode);
}
switch (OptionCode)
{
case 01:
Menu ();
Options ();
case 02:
TakeOrder ();
case 03:
exit (0);
}
}
while (OptionCode < 01 || OptionCode > 03);
printf("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
printf("\n *** Oops! The Option Code entered is not in the choices. Please try again: ");
scanf ("%i", &OptionCode);
}
//void function for TakeOrder
void TakeOrder (void)
{
do
{
printf("\n========================================================================================");
printf ("\n\t Welcome to Sunny Breakfast Hub's Order Section!");
printf("\n========================================================================================");
printf ("\n\nPlease input the Menu Code of your order: ");
scanf ("%i", &MenuCode);
switch (MenuCode)
{
//Breakfast Combos
case 101: printf("You ordered: Chicken 'n Waffles");
printf ("\nQuantity: ");
scanf ("%d", &quantity);
price = 280;
break;
case 102: printf("You ordered: Breakfast Burrito");
printf ("\nQuantity: ");
scanf ("%d", &quantity);
price = 230;
break;
case 103: printf("You ordered: All American Platter");
printf ("\nQuantity: ");
scanf ("%d", &quantity);
price = 400;
break;
case 104: printf("You ordered: Bacon Maniac w/ Eggs");
printf ("\nQuantity: ");
scanf ("%d", &quantity);
price = 300;
break;
case 105: printf("You ordered: Classic Eggs Benedict");
printf ("\nQuantity: ");
scanf ("%d", &quantity);
price = 250;
break;
case 106: printf("You ordered: Sausage Manic w/ Eggs");
printf ("\nQuantity: ");
scanf ("%d", &quantity);
price = 300;
break;
case 107: printf("You ordered: Fiesta Omelette");
printf ("\nQuantity: ");
scanf ("%d", &quantity);
price = 250;
break;
//All day sandwich
case 201: printf("You ordered: Honey Glazed Ham Sandwich");
printf ("\nQuantity: ");
scanf ("%d", &quantity);
price = 200;
break;
case 202: printf("You ordered: Tuna Mayo Sandwich");
printf ("\nQuantity: ");
scanf ("%d", &quantity);
price = 200;
break;
case 203: printf("You ordered: Chicken 'n Cheese Sandwich");
printf ("\nQuantity: ");
scanf ("%d", &quantity);
price = 180;
break;
case 204: printf("You ordered: Steak 'n Cheese Sandwich");
printf ("\nQuantity: ");
scanf ("%d", &quantity);
price = 250;
break;
case 205: printf("You ordered: Vegan Delight Sandwich");
printf ("\nQuantity: ");
scanf ("%d", &quantity);
price = 150;
break;
//Good Morning Pancakes
case 301: printf("You ordered: Mixed Berry Pancakes");
printf ("\nQuantity: ");
scanf ("%d", &quantity);
price = 180;
break;
case 302: printf("You ordered: Blueberry Pancakes");
printf ("\nQuantity: ");
scanf ("%d", &quantity);
price = 180;
break;
case 303: printf("You ordered: Chocolate Chip Pancakes");
printf ("\nQuantity: ");
scanf ("%d", &quantity);
price = 150;
break;
case 304: printf("You ordered: Banana Walnut Pancakes");
printf ("\nQuantity: ");
scanf ("%d", &quantity);
price = 150;
break;
//Sunny Coffee and Refreshments
case 401: printf("You ordered: Vanilla Milkshake");
printf ("\nQuantity: ");
scanf ("%d", &quantity);
price = 120;
break;
case 402: printf("You ordered: Cappucino");
printf ("\nQuantity: ");
scanf ("%d", &quantity);
price = 120;
break;
case 403: printf("You ordered: Mocha Frappucino");
printf ("\nQuantity: ");
scanf ("%d", &quantity);
price = 100;
break;
case 404: printf("You ordered: Fresh Orange Juice");
printf ("\nQuantity: ");
scanf ("%d", &quantity);
price = 80;
break;
}
SubTotal = price * quantity;
TotalPrice += SubTotal;
printf ("\nSubtotal: P%.2f", price);
printf (" * %i", quantity);
printf (" = P%.2f", SubTotal);
printf ("\n\nDo you want to purchase more?");
printf ("\n -> Press (1) if you want to purchase more.");
printf ("\n -> Press (0) if you want to proceed to checkout options.");
printf ("\n\nPlease enter (1/0) here: ");
scanf ("%i", &trial);
}
while (trial == 1);
OptionsGoingToReceipt ();
}
//void optionsgoingtoreceipt
void OptionsGoingToReceipt (void)
{
startoptionsreceipt: //goto starting point
printf("\n========================================================================================");
printf ("\n\t SUNNY BREAKFAST HUB CHECKOUT OPTIONS");
printf("\n========================================================================================");
printf ("\n\n >>> Your Total Bill is: P%.2f", TotalPrice);
printf ("\n\n10 Summary of your order (Show Receipt) ");
printf ("\n20 Back to Sunny Breakfast Hub Options ");
printf ("\n30 Exit Program");
printf("\n\n========================================================================================");
printf ("\n\nEnter the option number here: ");
scanf ("%d", &OptionReceipt);
if (OptionReceipt == 10)
{
Receipt ();
}
else if (OptionReceipt == 20)
{
Options ();
}
else if (OptionReceipt == 30)
{
exit (0);
}
else if (OptionReceipt != 10 || OptionReceipt != 20 || OptionReceipt != 30)
{
printf("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
printf("\n * Input error! The Option No. entered is not in the choices. Please try again. *");
printf("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
goto startoptionsreceipt; //repeat void OptionsGoingToReceipt
}
}
//void Receipt
void Receipt (void)
{
printf ("idk what to do"); ////help pls
}