Наш профессор компьютерного программирования поручил мне создать систему биллинга для ресторана. Кажется, все работает, за исключением квитанций. Я пытался найти способ напечатать количество, цены за единицу и итоговые значения. Тем не менее, мне трудно объявить переменные. Таким образом, квитанции показывают нули в трех упомянутых выше. Нуждаюсь в немедленной помощи. Спасибо!
#include <stdio.h>
int main()
{
while (Appet_Repeat == 0)
{
printf("Input the MEAL CODE of the appetizer you want to order.\n\n");
printf("*************************************[APPETIZERS]****************************************************************\n");
printf("MEAL CODE NAME \n\n");
printf(" 01 Mini Lasagna Bites Php 75.00/5 pcs. \n");
printf(" 02 Cheesy Dynamite Lumpia (Cheese-stuffed Chili Peppers) Php 65.00/6 pcs. <~> <#>\n");
printf(" 03 Buttery Garlic Bread Php 70.00/5 pcs. \n\n");
printf("Which appetizer would you like to order?\n");
scanf("%d", &Appetizer);
switch (Appetizer)
{
int MLB_quant;
int CDL_quant;
int BGB_quant;
int Appet_Decision;
float price_Appet1;
float price_Appet2;
float price_Appet3;
float total_MLB;
float total_CDL;
float total_BGB;
float totalprice_Appet;
case 01:
printf("You have chosen Mini Lasagna Bites.");
price_Appet1 = 75.00;
printf("Input the quantity of order:\n");
scanf("%d", &MLB_quant);
total_MLB = price_Appet1 * MLB_quant;
printf("Any additional appetizers you would like to order? (Input: 0 for No, 1 for Yes)");
scanf("%d", &Appet_Decision);
if(Appet_Decision == 0)
{
Appet_Repeat = 1;
totalprice_Appet = (total_MLB) + (total_CDL) + (total_BGB);
printf("Your initial bill is: Php %.2f", totalprice_Appet);
}
else if (Appet_Decision == 1)
{
Appet_Repeat = 0;
}
break;
case 02:
printf("You have chosen Cheesy Dynamite Lumpia.");
price_Appet2 = 65.00;
printf("Input the quantity of order:\n");
scanf("%d", &CDL_quant);
total_CDL = price_Appet2 * CDL_quant;
printf("Any additional appetizers you would like to order? (Input: 0 for No, 1 for Yes)");
scanf("%d", &Appet_Decision);
if(Appet_Decision == 0)
{
Appet_Repeat = 1;
totalprice_Appet = (total_MLB) + (total_CDL) + (total_BGB);
printf("Your initial bill is: Php %.2f", totalprice_Appet);
}
else if (Appet_Decision == 1)
{
Appet_Repeat = 0;
}
break;
case 03:
printf("You have chosen Buttery Garlic Bread.");
price_Appet3 = 70.00;
printf("Input the quantity of order:\n");
scanf("%d", &BGB_quant);
total_BGB = price_Appet3 * BGB_quant;
printf("Any additional appetizers you would like to order? (Input: 0 for No, 1 for Yes)");
scanf("%d", &Appet_Decision);
if(Appet_Decision == 0)
{
Appet_Repeat = 1;
totalprice_Appet = (total_MLB) + (total_CDL) + (total_BGB);
printf("Your initial bill is: Php %.2f", totalprice_Appet);
}
else if (Appet_Decision == 1)
{
Appet_Repeat = 0;
}
break;
default:
printf("Wrong order!");
break;
}
}
}
printf("Would you like to order some of our Main Courses and Desserts? (Input: 0 for No, 1 for Yes) \n\n");
scanf("%d", &category_Decision);
if(category_Decision == 0)
{
printf("\n");
printf("\t\t\t====================================================\n");
printf("\t\t\t\t CLARK N' NEA BILL\n");
printf("\t\t\t====================================================\n");
printf("\t\t\tQTY \t Description \t Unit Price (Php)\t Total Price (Php)\n");
printf("\t\t\t--- \t ----------- \t ---------- \t -----------\n\n");
printf("\t\t\t%d \t Mini Lasagna Bites %.2f %.2f \n", MLB_quant, price_Appet1, total_MLB);
printf("\t\t\t%d \t Cheesy Dynamite Lumpia %.2f %.2f \n", CDL_quant, price_Appet2, total_CDL);
printf("\t\t\t%d \t Buttery Garlic Bread %.2f %.2f \n", BGB_quant, price_Appet3, total_BGB);
printf("\t\t\t%d \t Grilled Tequila Bangus %.2f %.2f \n", GTB_quant, price_MainCou1, total_GTB);
printf("\t\t\t%d \t Creamy Beef Pasta %.2f %.2f \n\n", CBP_quant, price_MainCou2, total_CBP);
printf("\t\t\t%d \t Roasted Sweet Chili Chicken %.2f %.2f \n\n", RSCC_quant, price_MainCou3, total_RSCC);
printf("\t\t\t%d \t Chocolatey Chip Cookies %.2f %.2f \n\n", CCC_quant, price_Dessert1, total_CCC);
printf("\t\t\t%d \t Creamy Vanilla Cupcake %.2f %.2f \n\n", CVC_quant, price_Dessert2, total_CVC);
printf("\t\t\t%d \t Little Ice Cream %.2f %.2f \n\n", LIC_quant, price_Dessert3, total_LIC);
printf("\t\t\t====================================================\n\n");
total_Bill = totalprice_Appet + totalprice_MainCou + totalprice_Dessert;
printf("Your total bill is: %.2f", &total_Bill);
printf("Cash on hand? Input amount in Pesos and Centavos:");
scanf("%f", &Cash);
change = Cash - total_Bill;
printf("Your change is: %.2f", &change);
printf("Thank you for visiting Clark N' Nea! Enjoy and have a nice day! :)");
return 0;
}