need some advice on my program

i just dont know what's the error on this i already tried everythi

Page 1 of 1

6 Replies - 802 Views - Last Post: 14 March 2009 - 12:55 AM Rate Topic: -----

#1 awesomeSTEVE   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 13-March 09

need some advice on my program

Posted 13 March 2009 - 09:36 AM

#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <time.h>

float snacks(void);
char order();
float meal(void);
float beverages(void);
void pdata(void);
void price(void);
roder(void)';

char order()
{
	char ord,sord;
do{
	rorder();
	printf("[S] Snacks");
	printf("\n[M] Meal");
	printf("\n[B] Beverages");
	printf("\n[D] Desserts");
	

	flushall();
	printf("\n\nHUNGRY?Please choose your order: ");
	scanf("%c",&sord);	
	ord = toupper(sord);
	if(sord=='S'||sord=='M'||sord=='B'||sord=='D')
	{
	printf(""\nYou have chosen Order %c", sord);
	getch();
	}
	else
	{
	printf("Invalid Choice!\n");
	printf("Please Choose again");
	goto roder();
	}

float snacks()
{
	char schoice,x;
	int samount;
	float tscost = 0;

	printf("\n[A] Brownies 25php");
	printf("\n[B] Hot Cake 20php");
	printf("\n[C] Mango Float 30php");

	printf("\n\nWhich snack do you want to order: ");
	scanf("%s", &x);
	schoice = toupper(x);
	flushall();
	printf("\n\nYou have chosen order %c\n", schoice);
	switch(schoice)
	{
	case 'A':
			printf("How many Brownies do you want to buy? ");
			scanf("%d",&samount);
			tscost=(samount*25);
			printf("\nThe total cost is: PHP %.2f",tscost);
			break;
	case 'B':
			printf("How many Hot Cake do you want to buy? ");
			scanf("%d",&samount);
			tscost=(samount*20);
			printf("\nThe total cost is:PHP %.2f",tscost);
			break;
	case 'C':
			printf("How many Pizza do you want to buy? ");
			scanf("%d",&samount);
			tscost=(samount*30);
			printf("\nThe total cost is:PHP %.2f",tscost);
			break;

	}
	return tscost;
}

float meal()
{
	char mchoice,y;
	int mamount;
	float tmcost;

	printf("\n[A] 1pc Chicken w/ rice and drinks 55php");
	printf("\n[B] 2pcs Chicken w/ rice and drinks 70php");
	printf("\n[C] 2pcs Chicken w/ rice, Shake, and drinks 85php");

	printf("\n\nWhich Meal do you want to order: ");
	scanf("%s", &y);
	mchoice = toupper(y);
	flushall();
	printf("\n\nYou have chosen order %c\n", mchoice);
	switch(mchoice)
	{
	case 'A':
			printf("How many order of Meal A do you want to buy? ");
			scanf("%d",&mamount);
			tmcost=(mamount*55);
			printf("\nThe total cost is:PHP %.2f",tmcost);
			break;
	case 'B':
			printf("How many order of Meal B do you want to buy? ");
			scanf("%d",&mamount);
			tmcost=(mamount*70);
			printf("\nThe total cost is:PHP %.2f",tmcost);
			break;
	case 'C':
			printf("How many order of Meal C do you want to buy? ");
			scanf("%d",&mamount);
			tmcost=(mamount*85);
			printf("\nThe total cost is:PHP %.2f",tmcost);
	}
	return tmcost;

}
float beverages()
{
	char bchoice,z;
	int bamount;
	float tbcost;

	printf("\n[A] manggo juice 25php");
	printf("\n[B] Apple juice 25php");
	printf("\n[C] botomless ice tea 40php");
	orintf("\n[D] Bottle of Mineral Water 20php");

	printf("\n\nWhich beverage do you want to order: ");
	scanf("%s", &z);
	bchoice = toupper(z);
	flushall();
	printf("\n\nYou have chosen order %c\n", bchoice);
	switch(bchoice)
	{
	case 'A':
			printf("\nHow many mango juice do you want to buy? ");
			scanf("%d",&bamount);
			tbcost=(bamount*25);
			printf("\nThe total cost is:PHP %.2f",tbcost);
			break;
	case 'B':
			printf("\nHow many Apple juice do you want to buy? ");
			scanf("%d",&bamount);
			tbcost=(bamount*25);
			printf("\nthe total cost is: PHP %.2f", tbcost);
			break;
	case 'C':
			printf("\nHow many ice tea do you want to buy? ");
			scanf("%d",&bamount);
			tbcost=(bamount*40);
			printf("The total cost is: PHP %.2f", tbcost);
			break;
	case 'D':
			printf("\nHow many Bottle of Mineral Water do you want to buy? ");
			scanf("%d",&bamount);
			tbcost=(bamount*20);
			printf("The total cost is: PHP %.2f", tbcost);
			break;
	}
	return tbcost;
}
float desserts()
{
	char dchoice,a;
	int damount;
	float tdcost;

	printf("\n[A] manggo float 40php per serving");
	printf("\n[B] salad 35php per serving");
	printf("\n[C] chocolate cake 40php per slice");
	printf("\n[D] baked macaroni 45php per serving");

	printf("\n\nWhich dessert do you want to order: ");
	scanf("%s", &a);
	dchoice = toupper(a);
	flushall();
	printf("\n\nYou have chosen order %c\n", dchoice);
	switch(dchoice)
	{
	case 'A':
			printf("How many mango float do you want to buy? ");
			scanf("%d",&damount);
			tdcost=(damount*40);
			printf("\nThe total cost is:PHP %.2f",tdcost);
			break;
	case 'B':
			printf("How many salad do you want to buy? ");
			scanf("%d",&damount);
			tdcost=(damount*35);
			printf("\nThe total cost is:PHP %.2f",tdcost);
			break;
	case 'C':
			printf("How many chocolate cake do you want to buy? ");
			scanf("%d",&damount);
			tdcost=(damount*40);
			printf("\nThe total cost is:PHP %.2f",tdcost);
			break;
	case 'D':
			printf("How many baked macaroni do you want to buy? ");
			scanf("%d",&damount);
			tdcost=(damount*45);
			printf("\nThe total cost is:PHP %.2f",tdcost);
			break;
	}
	return tdcost;
}
void pdata()
{
	char ans;
	
	char lname2[30];
	char fname2[30];
	char mi2[3];
	char lname[30];
	char fname[30];
	char mi[3];
	
do{
		clrscr();
	flushall();
	printf("enter your first name: ");
	gets(fname);
	flushall();
	printf("enter you last name: ");
	gets(lname);
	flushall();
	printf("enter your middle initial: ");
	gets(mi);
	flushall();
	

	printf("\nAre entries correct?[Y/N] ");
	scanf("%c", &ans);
	ans = toupper(ans);

	if(ans=='Y')
	{
	strcpy(fname2,fname);
	printf("FirstName: %s\n", fname2);
	strcpy(lname2,lname);
	printf("LastName: %s\n", lname2);
	strcpy(mi2,mi);
	printf("MiddleInitial: %s\n", mi2);
	strcpy(id2,id_num);
	
	}
}while(toupper(ans) == 'N');

getch();

}

void price()
{
	float tamount=0,tvat=0,tchange=0,tpay=0,tscost=0,tdcost=0,tmcost=0,tbcost=0;
	char choice = order();

	clrscr();
	flushall();


	if(choice == 'S')
	{
		tscost = snacks();
	}
	else if(choice== 'M')
	{
		tmcost = meal();
	}
	else if(choice== 'B')
	{
		tbcost = beverages();
	}
	else if (choice== 'D')
	{
		tdcost = desserts();
	}else
		printf("pls choose again");

	getch();
	tamount= tscost+tdcost+tmcost+tbcost;
	printf("\nTotal amount to be paid: %.2f\n");
	printf("\nEnter you payment: ");
	scanf("%f", &tpay);
	tamount= (tamount);
	tchange=(tpay - tamount);
	if(tchange<0)
	{
	printf("\n insufficient funds...");
	}
	else{

	printf("\nyour change is: %.2f",tchange);
	printf("\n\nThank you! Buy Again");
	}
}



void main()
{
	pdata();
	clrscr();
	price();
	getch();
}




Is This A Good Question/Topic? 0
  • +

Replies To: need some advice on my program

#2 JackOfAllTrades   User is offline

  • Saucy!
  • member icon

Reputation: 6259
  • View blog
  • Posts: 24,028
  • Joined: 23-August 08

Re: need some advice on my program

Posted 13 March 2009 - 09:49 AM

What's the error?

This
roder(void)';


is certainly wrong.
Was This Post Helpful? 0
  • +
  • -

#3 awesomeSTEVE   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 13-March 09

Re: need some advice on my program

Posted 13 March 2009 - 04:49 PM

View PostJackOfAllTrades, on 13 Mar, 2009 - 08:49 AM, said:

What's the error?

This
roder(void)';


is certainly wrong.



what should i put in the code??

can you give me an idea
Was This Post Helpful? 0
  • +
  • -

#4 Hyper   User is offline

  • Banned

Reputation: 108
  • View blog
  • Posts: 2,129
  • Joined: 15-October 08

Re: need some advice on my program

Posted 13 March 2009 - 04:55 PM

void roder();

Perhaps?

EDIT: Um, unless I'm mistaken, in C you're supposed to use LABEL's and GOTO's not functions and gotos.
Example:
MyLabel:
    printf("Hi!\n");
    goto MyLabel;


Oh, and welcome to DIC.

This post has been edited by Hyper: 13 March 2009 - 04:58 PM

Was This Post Helpful? 0
  • +
  • -

#5 F!st!cuffs   User is offline

  • D.I.C Head

Reputation: 12
  • View blog
  • Posts: 153
  • Joined: 15-July 08

Re: need some advice on my program

Posted 13 March 2009 - 05:01 PM

There's a lot of spelling errors too.

Try this:

Compile your code.
If no_errors == true you have a working program
else start with the first error - fix it
goto second error - fix it
recompile your code every now and then as fixing one error may fix more than one
Rinse/Repeat and eventually it will work.
Was This Post Helpful? 0
  • +
  • -

#6 Hyper   User is offline

  • Banned

Reputation: 108
  • View blog
  • Posts: 2,129
  • Joined: 15-October 08

Re: need some advice on my program

Posted 13 March 2009 - 05:04 PM

Dude, that was awesome! Thanks F!st!cuffs, I'm going to print and post that on my wall! :)
Was This Post Helpful? 0
  • +
  • -

#7 Armie   User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 79
  • Joined: 09-August 08

Re: need some advice on my program

Posted 14 March 2009 - 12:55 AM

Also, please don't use GOTOs. They are the source of all evil (along with pointers, that is, but pointers are lesser evil). You will find later on when your programs become larger that your use of GOTOs will make your code scary to look at. I had a teacher once say "ok there is this thing called GOTO, it does this and that, and this is how you use it. Now, forget that I ever told you about it."
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1