我已经把有问题的Bold起来了,希望各位高手帮忙找出解决方案。
谢谢!
#include <stdio.h>
#include <time.h>
int main()
{
int tbnum, pznum, drknum, pzq, drkq;
char custname[175], pz[12], drk[10];
const double pzpr = 8.50, drkpr = 3.20;
double psub, dsub, ttch, ttpay, tax, paid, chg;
struct tm * timeinfo;
time_t lt;
printf("\t--- Welcome to Pizza House Restaurant ---\n\n");
// Show Pizza and Drinks Menu
printf("PIZZA MENU\n 1.Pepperoni\n 2.Seafood\n 3.Vegetable\n 4.Hawaiian\n 5.Mixed Combo\n");
printf("\nDRINKS MENU\n 1.Juice\n 2.Chocolate\n 3.Cocktail\n 4.Latte\n");
// Prompt User Input Order Information
printf("\nPlease enter table number\t: ");
scanf("%d", &tbnum);
fflush(stdin);
printf("Please enter your name\t\t: ");
gets(custname);
printf("Enter choice of pizza\t\t: ");
scanf("%d", &pznum);
fflush(stdin);
// If Else Statement limiting the pizza choice
if (pznum > 5) {
printf("ERROR\nWe do not have that on the menu, please re-enter your choice!\n");
printf("Enter choice of pizza\t\t: ");
scanf("%d", &pznum);
fflush(stdin);
}
else { // Do Nothing
}
printf("Enter quantity of the pizza\t: ");
scanf("%d", &pzq);
fflush(stdin);
printf("\nEnter choice of drink\t\t: ");
scanf("%d", &drknum);
fflush(stdin);
// If Else Statement limiting the drink choice
if (drknum > 4) {
printf("ERROR\nWe do not have that on the menu, please re-enter your choice!\n");
printf("Enter choice of drink\t\t: ");
scanf("%d", &drknum);
fflush(stdin);
}
else { // Do Nothing
}
printf("Enter quantity of the drink\t: ");
scanf("%d", &drkq);
fflush(stdin);
// Show Order Summary
printf("\nOrder Summary:\n--------------\n");
time(<); // Get Date/Time
timeinfo = localtime(<);
printf("Date/Time\t: %s", asctime(timeinfo));
printf("Table Number\t: %d\n", tbnum);
printf("Customer Name\t: %s\n", custname);
printf("\nItem\t\tUnit Price (RM)\t\tQuantity\tSub-Total (RM)\n");
printf("-----\t\t---------------\t\t--------\t--------------\n");
psub = pzpr * pzq;
if (pznum == 1) {
pz = "Pepperoni";
}
else { // Do Nothing
}
printf("%-s\t\t%.2lf\t\t %d\t\t\t%.2lf\n", pz, pzpr, pzq, psub);
dsub = drkpr * drkq;
printf("%-s\t\t%.2lf\t\t %d\t\t\t %.2lf\n", drk, drkpr, drkq, dsub);
printf("\t\t\t\t\t\t\t--------------\n");
ttch = psub + dsub;
printf("\t\t\t\t\tTotal Charge:\t\t%.2lf\n", ttch);
tax = ttch * 0.1;
printf("\t\t\t\t\tService Tax(10%):\t %.2lf\n", tax);
ttpay = ttch + tax;
printf("\t\t\t\t\t\t\t==============\n\t\t\t\t\tTotal Payment:\t\t%.2lf\n\t\t\t\t\t\t\t==============\n", ttpay);
// Prompt User Input on Cash Paid
printf("\t\t\t\t\tPaid Cash:\tRM\t");
scanf("%lf", &paid);
fflush(stdin);
chg = paid - ttpay;
printf("\t\t\t\t\tCHANGE:\t\tRM\t%.2lf\n", chg);
printf("\nALWAYS THE PREFERRED CHOICE!\n");
printf("\tPizza House Restaurant (482123-0)\n\t53300 Setapak, Kuala Lumpur.\n");
printf("\n%s, thank you for visiting Pizza House Restaurant (482123-0)!!\nHave a nice day. Please come again ~~!", custname);
return 0;
}





你是指甚麼限制呢??