My question is: If i'm the customer, how can i edit the quantity shown on the overview so that i can afford to pay the totalprice(if i've ordered too much) and delete some on the overview if i want to delete it(really short on money).
And if i'm the owner of my meatshop, how can i see what products have been sold and the quantity?
I want to do this on my own but i can't seem to think of a way to do this. Hope someone can help me with this.
here's my code..
#include <stdio.h>
#include <string.h>
#include <conio.h>
#include <ctype.h>
#define TAX_RATE 0.12
#define MAX 23
#define LENGTH 30
struct menuItemType
{
char menuItem[LENGTH];
float menuPrice;
float Total;
float numOrdered;
}theMenu[MAX];
void initialize(void);
int menu(void);
void lamb(void);
void beef(void);
void pork(void);
float order(void);
void utro(void);
void overView(void);
void resibo(void);
float edit(int);
int choice;
int or_num = 100;
float pbill=0;
float bill=0;
float totalTax=0;
float totalItems=0;
int y;
float change;
float pay=0;
int main(void)
{
int choyz;
do
{
choyz = menu();
if(choyz==1) lamb();
else if(choyz==2) pork();
else if(choyz==3) beef();
else if(choyz==4) gotoxy(30,16);textcolor(WHITE);
printf("Salamat Lamang!");getch();textmode(LASTMODE); exit();
}while(choyz<1 || choyz >4);
}
/* Initialize */
void initialize(void){
for (y = 0; y <= MAX; y++)
{
theMenu[y].numOrdered = 0;
theMenu[y].Total = 0;
theMenu[y].menuPrice = 0;
strcpy(theMenu[y].menuItem,"");
}
}
/* MAIN MENU */
int menu(void){
clrscr();
choice=0;
do{
gotoxy(25,3);printf("ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»");
gotoxy(25,4);printf("º PORKY'S MEAT SHOP º");
gotoxy(25,5);printf("ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ");
gotoxy(33,8);printf("[1] Lamb");
gotoxy(33,9);printf("[2] Pork");
gotoxy(33,10);printf("[3] Beef");
gotoxy(33,12);printf("[4] Exit");
gotoxy(30,14);textcolor(BLACK);textbackground(WHITE);cprintf("Enter Choice:");
choice = getch();
textmode(LASTMODE);
}while(choice<1 || choice>4);
return choice;
}
/* LAMB */
void lamb(void){
clrscr();
do{
gotoxy(19,5);printf("[1]Lamb Chops P 120.00");
gotoxy(19,6);printf("[2]Lamb Stew P 110.00");
gotoxy(19,7);printf("[3]Lamb Shank P 140.00");
gotoxy(19,8);printf("[4]Lamb Leg P 120.00");
gotoxy(19,9);printf("[5]Lamb Rack P 170.00");
gotoxy(19,10);printf("[6]Midloin Chops P 150.00");
gotoxy(19,11);printf("[7]Rib of Lamb P 140.00");
gotoxy(19,13);printf("[8]Back to Main");
gotoxy(33,15);textcolor(BLUE);textbackground(WHITE);cprintf("Enter Choice: ");
choice = getch();
}while(choice<1 || choice>8);
textmode(LASTMODE);
choice-=1;
switch(choice){
case 0: strcpy(theMenu[choice].menuItem,"Lamb Chops");
theMenu[choice].menuPrice=120.00;
theMenu[choice].numOrdered=order();
theMenu[choice].Total= (theMenu[choice].menuPrice * theMenu[choice].numOrdered);
utro();
break;
case 1: strcpy(theMenu[choice].menuItem,"Lamb Stew");
theMenu[choice].menuPrice=110.00;
theMenu[choice].numOrdered=order();
theMenu[choice].Total= (theMenu[choice].menuPrice * theMenu[choice].numOrdered);
utro();
break;
case 2: strcpy(theMenu[choice].menuItem,"Lamb Shank");
theMenu[choice].menuPrice=140.00;
theMenu[choice].numOrdered=order();
theMenu[choice].Total= (theMenu[choice].menuPrice * theMenu[choice].numOrdered);
utro();
break;
case 3: strcpy(theMenu[choice].menuItem,"Lamb Leg");
theMenu[choice].menuPrice=120.00;
theMenu[choice].numOrdered=order();
theMenu[choice].Total= (theMenu[choice].menuPrice * theMenu[choice].numOrdered);
utro();
break;
case 4: strcpy(theMenu[choice].menuItem,"Lamb Rack");
theMenu[choice].menuPrice=170.00;
theMenu[choice].numOrdered=order();
theMenu[choice].Total= (theMenu[choice].menuPrice * theMenu[choice].numOrdered);
utro();
break;
case 5: strcpy(theMenu[choice].menuItem,"Midloin Chops");
theMenu[choice].menuPrice=150.00;
theMenu[choice].numOrdered=order();
theMenu[choice].Total= (theMenu[choice].menuPrice * theMenu[choice].numOrdered);
utro();
break;
case 6: strcpy(theMenu[choice].menuItem,"Rib of Lamb");
theMenu[choice].menuPrice=140.00;
theMenu[choice].numOrdered=order();
theMenu[choice].Total= (theMenu[choice].menuPrice * theMenu[choice].numOrdered);
utro();
break;
default: main();
break;
}
}
/* PORK */
void pork(void){
clrscr();
do{
gotoxy(19,5);printf("[1]Tenderloin P 220.00");
gotoxy(19,6);printf("[2]Pork Sukiyaki P 250.00");
gotoxy(19,7);printf("[3]Butterfly Cut P 210.00");
gotoxy(19,8);printf("[4]Pork Cutlets P 180.00");
gotoxy(19,9);printf("[5]Porkchop P 260.00");
gotoxy(19,10);printf("[6]Bacon Slice P 300.00");
gotoxy(19,11);printf("[7]Pork Steak P 200.00");
gotoxy(19,13);printf("[8]Back to Main");
gotoxy(33,15);textcolor(BLUE);textbackground(WHITE);cprintf("Enter Choice: ");
choice = getch();
}while(choice<1 || choice>8);
textmode(LASTMODE);
choice+=7;
switch(choice){
case 8: strcpy(theMenu[choice].menuItem,"Tenderloin");
theMenu[choice].menuPrice=220.00;
theMenu[choice].numOrdered=order();
theMenu[choice].Total= (theMenu[choice].menuPrice * theMenu[choice].numOrdered);
utro();
break;
case 9: strcpy(theMenu[choice].menuItem,"Pork Sukiyaki");
theMenu[choice].menuPrice=250.00;
theMenu[choice].numOrdered=order();
theMenu[choice].Total= (theMenu[choice].menuPrice * theMenu[choice].numOrdered);
utro();
break;
case 10: strcpy(theMenu[choice].menuItem,"Butterfly Cut");
theMenu[choice].menuPrice=210.00;
theMenu[choice].numOrdered=order();
theMenu[choice].Total= (theMenu[choice].menuPrice * theMenu[choice].numOrdered);
utro();
break;
case 11: strcpy(theMenu[choice].menuItem,"Pork Cutlets");
theMenu[choice].menuPrice=180.00;
theMenu[choice].numOrdered=order();
theMenu[choice].Total= (theMenu[choice].menuPrice * theMenu[choice].numOrdered);
utro();
break;
case 12: strcpy(theMenu[choice].menuItem,"Porkchop");
theMenu[choice].menuPrice=260.00;
theMenu[choice].numOrdered=order();
theMenu[choice].Total= (theMenu[choice].menuPrice * theMenu[choice].numOrdered);
utro();
break;
case 13: strcpy(theMenu[choice].menuItem,"Bacon Slice");
theMenu[choice].menuPrice=300.00;
theMenu[choice].numOrdered=order();
theMenu[choice].Total= (theMenu[choice].menuPrice * theMenu[choice].numOrdered);
utro();
break;
case 14: strcpy(theMenu[choice].menuItem,"Pork Steak");
theMenu[choice].menuPrice=200.00;
theMenu[choice].numOrdered=order();
theMenu[choice].Total= (theMenu[choice].menuPrice * theMenu[choice].numOrdered);
utro();
break;
default: main();
break;
}
}
/* BEEF */
void beef(void){
clrscr();
do{
gotoxy(19,5);printf("[1]Tenderloin P 200.00");
gotoxy(19,6);printf("[2]Striploin P 210.00");
gotoxy(19,7);printf("[3]Stroganoff P 230.00");
gotoxy(19,8);printf("[4]Morcon Slice P 290.00");
gotoxy(19,9);printf("[5]Beef Cubes P 200.00");
gotoxy(19,10);printf("[6]Beef Steak P 230.00");
gotoxy(19,11);printf("[7]Sirloin P 225.00");
gotoxy(19,13);printf("[8]Back to Main");
gotoxy(33,15);textcolor(BLUE);textbackground(WHITE);cprintf("Enter Choice: ");
choice = getch();
}while(choice<1 || choice>8);
textmode(LASTMODE);
choice+=15;
switch(choice){
case 16: strcpy(theMenu[choice].menuItem,"Tenderloin");
theMenu[choice].menuPrice=200.00;
theMenu[choice].numOrdered=order();
theMenu[choice].Total= (theMenu[choice].menuPrice * theMenu[choice].numOrdered);
utro();
break;
case 17: strcpy(theMenu[choice].menuItem,"Striploin");
theMenu[choice].menuPrice=210.00;
theMenu[choice].numOrdered=order();
theMenu[choice].Total= (theMenu[choice].menuPrice * theMenu[choice].numOrdered);
utro();
break;
case 18: strcpy(theMenu[choice].menuItem,"Stroganoff");
theMenu[choice].menuPrice=230.00;
theMenu[choice].numOrdered=order();
theMenu[choice].Total= (theMenu[choice].menuPrice * theMenu[choice].numOrdered);
utro();
break;
case 19: strcpy(theMenu[choice].menuItem,"Morcon Slice");
theMenu[choice].menuPrice=290.00;
theMenu[choice].numOrdered=order();
theMenu[choice].Total= (theMenu[choice].menuPrice * theMenu[choice].numOrdered);
utro();
break;
case 20: strcpy(theMenu[choice].menuItem,"Beef Cubes");
theMenu[choice].menuPrice=200.00;
theMenu[choice].numOrdered=order();
theMenu[choice].Total= (theMenu[choice].menuPrice * theMenu[choice].numOrdered);
utro();
break;
case 21: strcpy(theMenu[choice].menuItem,"Beef Steak");
theMenu[choice].menuPrice=230.00;
theMenu[choice].numOrdered=order();
theMenu[choice].Total= (theMenu[choice].menuPrice * theMenu[choice].numOrdered);
utro();
break;
case 22: strcpy(theMenu[choice].menuItem,"Sirloin");
theMenu[choice].menuPrice=225.00;
theMenu[choice].numOrdered=order();
theMenu[choice].Total= (theMenu[choice].menuPrice * theMenu[choice].numOrdered);
utro();
break;
default: main();
break;
}
}
/* ORDER */
float order(void)
{
float g;
do{
gotoxy(33,17);printf("How many kilos? ");
scanf("%f",&g);
}while(g<0);
return g;
}
/* UTRO */
void utro(void){
char again;
do{
gotoxy(33,19);printf("Order Again? (Y/N)");
again = getch();
again=toupper(again);
}while(again!='Y' && again!='N');
if(again=='Y') main();
else overView();
}
/* overView */
void overView(void)
{
char what;
int k=0;
clrscr();
gotoxy(34,3);printf("ÉÍÍÍÍÍÍÍÍÍÍ»");
gotoxy(34,4);printf("º Overview º");
gotoxy(34,5);printf("ÈÍÍÍÍÍÍÍÍÍͼ");
gotoxy(5,7);printf("#");
gotoxy(10,7);printf("Quantity");
gotoxy(32,7);printf("Item");
gotoxy(55,7);printf("Price");
gotoxy(70,7);printf("Subtotal\n");
for (y = 0; y <= MAX; y++)
{
if (theMenu[y].numOrdered > 0)
{
gotoxy(5,9+k);printf("%d",k+1);
gotoxy(10,9+k);printf("%.2f",theMenu[y].numOrdered);
gotoxy(29,9+k);printf("%s",theMenu[y].menuItem);
gotoxy(55,9+k);printf("P %.2f",theMenu[y].menuPrice);
gotoxy(70,9+k);printf("P %2.2f",theMenu[y].Total);
k++;
}
}
for(y = 0; y <= MAX; y++)
{
if (theMenu[y].Total>0)
bill+=theMenu[y].Total;
if (theMenu[y].numOrdered>0)
totalItems+=theMenu[y].numOrdered;
}
do{
gotoxy(5,MAX);printf("Total Items: %-2.2f",totalItems);
gotoxy(62,MAX);printf("Total : P %.2f",bill);
gotoxy(30,MAX);printf("Continue? (Y/N)");
what = getch();
what=toupper(what);
}while(what!='Y' && what!='N');
if (what=='Y'){
gotoxy(30,MAX+1);printf("Enter Cash Amount: ");
scanf("%f",&pay);
if (isdigit(pay)==1)
{
if (pay<bill)
{
printf("\n\t\t\tInsufficient funds!"); getch();
overView();
}else{
change = pay - bill;
totalTax = bill * TAX_RATE;
pbill = bill - totalTax;
resibo();
getch();
}
}else{
printf("Only Numbers allowed"); getch();
overView();
}else main();
}
/* RESIBO */
void resibo(void){
clrscr();
gotoxy(31,2);printf("PORKY'S MEAT SHOP");
gotoxy(30,3);printf("Agora Road, Disneyland");
gotoxy(28,5);printf("------------------------------\n\n");
gotoxy(28,7);printf("VATABLE Sales : %11.2f",pbill);
gotoxy(28,8);printf("VAT Amount : %11.2f",totalTax);
gotoxy(28,9);printf("Amount Due : %11.2f",bill);
gotoxy(28,10);printf("-------------------------------\n\n");
gotoxy(28,12);printf("Cash : %10.2f",bill);
gotoxy(28,13);printf("Change : %10.2f",change);
gotoxy(28,14);printf("TotalItems : %10.2f",totalItems);
gotoxy(28,15);printf("OR # : %10d",or_num);
or_num++;
getch();
initialize();
main();
}