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();
}

Recommended Answers

All 5 Replies

You need to use an int to keep the number of items sold. Also use a switch/case to choose whether customer or owner.

You need to use an int to keep the number of items sold. Also use a switch/case to choose whether customer or owner.

I can't use int, what if the customer will order 2.5 kilos? and... the customer-owner things is done.. what i need is how to edit the overview and how to put info on a file(file handling).

>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).

Well, you can display all your menu with the corresponding values next to it. And at the bottom of the above menu you could have one more horizon menu with the C-Calculate, D-Delete etc etc. This would allow the user to edit the qty value and to re-calculate the price press ‘C’ and that your probably clear the screen the then display the new value or the updated value. Or you don’t have to clear the screen. Perhaps, just update the value at the x & y position. Since, they are more fixed in your case.

>And if i'm the owner of my meatshop, how can i see what products have been sold and the quantity?
Well, if you wanted to use files handling, then probably you will have to record all the details of qty and the total price for each transaction. Its up to you on how do you want to write them onto the file.

1. Place them in the structure and then write the structure.
2. You could store them in a variable and then write the variable to the file.

If you want to know more about the file handling google file handling in C.

There are few things which I will have to point out before anything can be said. It looks like that your using library functions which are not portable. Especially the conio.h and function defined under that library are not portable. You should seriously think of upgrading your compiler. Use Dev-C++ or the Code:Block. Then both use the mingW port which connects to the GCC.

And also that show snap shorts of your code on where you need help. Rather then posting them all here. That’s that helpful and you wouldn’t get much help :)

-ssharish


Well, you can display all your menu with the corresponding values next to it. And at the bottom of the above menu you could have one more horizon menu with the C-Calculate, D-Delete etc etc. This would allow the user to edit the qty value and to re-calculate the price press ‘C’ and that your probably clear the screen the then display the new value or the updated value. Or you don’t have to clear the screen. Perhaps, just update the value at the x & y position. Since, they are more fixed in your case.

If the user wants to delete, then he/she will change the quantity to 0.

There are few things which I will have to point out before anything can be said. It looks like that your using library functions which are not portable. Especially the conio.h and function defined under that library are not portable. You should seriously think of upgrading your compiler. Use Dev-C++ or the Code:Block. Then both use the mingW port which connects to the GCC.

My instructor wants to use the very basic Borland v2.01. He wants us to learn the basic first before using high level programming languages.

And also that show snap shorts of your code on where you need help. Rather then posting them all here. That’s that helpful and you wouldn’t get much help :)
-ssharish

Ok I will do this the next time i post.

thank you for all the help.. i've done this already. thank you for the links also in learning C. i've learned a lot

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.