printf("I NEED YOUR HELP");

good evening programmers
does anyone know what is the wrong with my program, once i run it and calculate the total price ..i get many numbers that aren't included to the calculation process.

could anybody tell me how can i fix it

here is my program :
----------------------------------------------------------------------------
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>

main()
{
//variable declaration
int BAGEL;
int WHITEBREAD;
int GRAINBREAD;
int PITABREAD;
int SOURDOUGHBREAD;
int REYBREAD;
int WHEATTORTILLA;
int FRENCHBREAD;
int p1,p2,p3,p4,p5,p6,p7,p8;
int BREAD;
char DECISION,order;
float TOTALPRICE;
//assignement
;printf("\t\t\t\tWELCOM TO SAID'S BAKERY.\n\n\t\t\t\tPLEASE SELECT YOUR BREAD\n\n");
printf("\n\t\t\t\t[1]BAGEL\n\t\t\t\t[2]WHITE BREAD\n\t\t\t\t[3]GRAIN BREAD\n\t\t\t\t[4]PITA BREAD\n\t\t\t\t[5]SOURDOUGH BREAD\n\t\t\t\t[6]REY BREAD\n\t\t\t\t[7]WHEAT BREAD\n\t\t\t\t[8]FRENCH BREAD\n",BREAD);
scanf("%d", &BREAD);
switch(BREAD){
case 1: system("cls");
system("color E0");
printf("\nYOU HAVE CHOSEN BAGEL\n\nTHE PRICE OF A SINGLE PIECE IS 2.5$\n",BAGEL);
printf("\n\n-----------------------------------------------------");
printf("\n\nHOW MANY PIECES DO YOU NEED?\n\n");
scanf("%d", &p1);
printf("\n\n------------------------------------------------------------");
BAGEL=p1*2.5;
printf("\n\n\nTHE TOTAL PRICE IS:\t%d $$\n\n",BAGEL);
break;
case 2: system("cls");
system("color E0");
printf("\nYOU HAVE CHOSEN WHITE BREAD\n\nTHE PRICE OF A SINGLE PIECE IS 0.99$\n");
printf("\n\n-----------------------------------------------------");
printf("\nHOW MANY PIECES DO YOU NEED?\n\n");
scanf("%d", &p2);
printf("\n\n------------------------------------------------------------");
WHITEBREAD=p2*0.99;
printf("\nTHE TOTAL PRICE IS:\t%d $$\n\n",WHITEBREAD);
break;
case 3: system("cls");
system("color E0");
printf("\nYOU HAVE CHOSEN GRAIN BREAD\n\nTHE PRICE OF A SINGLE PIECE IS 2$\n");
printf("\n\n-----------------------------------------------------");
printf("\nHOW MANY PIECES DO YOU NEED?\n\n");
scanf("%d",&p3);
printf("\n\n------------------------------------------------------------");
GRAINBREAD=p3*2.0;
printf("\nTHE TOTAL PRICE IS:\t %d $$\n\n",GRAINBREAD);
break;
case 4: system("cls");
system("color E0");
printf("\nYOU HAVE CHOSEN PITA BREAD\n\nTHE PRICE OF A SINGLE PIECE IS 2.1$\n");
printf("\n\n-----------------------------------------------------");
printf("\nHOW MANY PIECES DO YOU NEED?\n\n");
scanf("%d",&p4);
printf("\n\n------------------------------------------------------------");
PITABREAD=p4*2.1;
printf("\nTHE TOTAL PRICE IS:\t%d $$\n\n",PITABREAD);
break;
case 5: system("cls");
system("color E0");
printf("\nYOU HAVE CHOSEN SOURDOUGH BREAD\n\nTHE PRICE OF A SINGLE PIECE IS 1.5$\n");
printf("\n\n-----------------------------------------------------");
printf("\nHOW MANY PIECES DO YOU NEED?\n\n");
scanf("%d",&p5);
printf("\n\n------------------------------------------------------------");
SOURDOUGHBREAD=p5*1.5;
printf("\nTHE TOTAL PRICE IS :\t%d $$\n\n",SOURDOUGHBREAD);
break;
case 6: system("cls");
system("color E0");
printf("\nYOU HAVE CHOSEN REY BREAD\n\nTHE PRICE OF A SINGLE PIECE IS 1.1$\n");
printf("\n\n-----------------------------------------------------");
printf("\nHOW MANY PIECES DO YOU NEED?\n\n");
scanf("%d",&p6);
printf("\n\n------------------------------------------------------------");
REYBREAD=p6*1.1;
printf("\nTHE TOTAL PRICE IS: \t%.2f $$\n\n",REYBREAD);
break;
case 7 :system("cls");
system("color E0");
printf("\nYOU HAVE CHOSEN WHEAT TORTILLA\n\nTHE PRICE OF A SINGLE PIECE IS 1$\n");
printf("\n\n-----------------------------------------------------");
printf("\nHOW MANY PIECES DO YOU NEED?\n\n");
scanf("%d",&p7);
printf("\n\n------------------------------------------------------------");
WHEATTORTILLA=p7*1.0;
printf("\nTHE TOTAL PRICE IS :\t%d $$\n\n",WHEATTORTILLA);
break;
case 8 : system("cls");
system("color E0");
printf("\nYOU HAVE CHOSEN FRENCH BREAD\n\nTHE PRICE OF A SINGLE PIECE IS 0.89$\n");
printf("\n\n-----------------------------------------------------");
printf("\nHOW MANY PIECES DO YOU NEED?\n\n");
scanf("%d",&p8);
printf("\n\n------------------------------------------------------------");
FRENCHBREAD=p8*0.89;
printf("\nTHE TOTAL PRICE IS :\t%d $$\n\n",FRENCHBREAD);
break;
default:printf("\n\nNO AVAILABLE OPTIONS\n\n");
}
//computation
printf("\n\n--------------------------------------------------------------------");
printf("\n\nWOULD YOU LIKE TO MAKE ANOTHER ORDER?\n\n[ NOTICE:press (y) to go back to the menu\n\t\t(n) to leave ].\n ",DECISION);
scanf("%s",&DECISION);
switch(DECISION){
case'y':system("cls");
return main();
break;

case'n': system("cls");
printf("ORDERS\n");
if(p1!=0;p2!=0;p3!=0;p4!=0;p5!=0;p6!=0;p7!=0;p8!=0)
{
printf("\nBAGEL = \t\t %d $$", BAGEL);}
{
printf("\nWHITE BREAD = \t\t %d $$",WHITEBREAD);}
{
printf("\nGRAIN BREAD = \t\t %d $$",GRAINBREAD);}
{
printf("\nPITA BREAD = \t\t %d $$",PITABREAD); }
{
printf("\nSOURDOUGH BREAD = \t %d $$",SOURDOUGHBREAD);}
{
printf("\nREY BREAD = \t\t %d $$",REYBREAD);}
{
printf("\nWHEAT TORTILLA = \t %d $$",WHEATTORTILLA);}
{
printf("\nFRENCH BREAD = \t %d $$",FRENCHBREAD);}

TOTALPRICE=BAGEL+WHITEBREAD+GRAINBREAD+PITABREAD+SOURDOUGHBREAD+REYBREAD+WHEATTORTILLA+FRENCHBREAD;
printf("\n\nTHE TOTAL AMOUNT IS %.2f\n\n",TOTALPRICE);
}

system("pause");
return(0);
}



I'm not going to look through the whole code (and probably nobody else will), because you didn't use code tags (press edit then highlight your code and press the <> button). But in the first section, you multiply integers by decimals, which a significant amount of time will come out with the wrong result. You also have an excessive use of system functions, which have been extensively discussed and determined to be a bad thing, though probably isn't causing these problems.
Topic archived. No new replies allowed.