Click here to Skip to main content
15,892,768 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C++
#include<stdio.h>

int  printMenu()

{


int response;

fprintf(stdout,"\n\n\n               *********************************************\n");
fprintf(stdout,"			        FOOD COURT		  \n ");
fprintf(stdout,"              *********************************************\n\n\n");
fprintf(stdout,"                         Welcome to the Food court   \n\n");
fprintf(stdout,"    Make your selection from the given MENU below:\n\n\n");

fprintf(stdout,"	 1. Thums up			            60.00   \n");
fprintf(stdout,"	 2. Sprite			            60.00   \n");
fprintf(stdout,"	 3. Coke			            60.00   \n");
fprintf(stdout,"	 4. Regular Cheeseburger		    45.00   \n");
fprintf(stdout,"	 5. Fish Sandwich			    70.00   \n");
fprintf(stdout,"	 6. French fries			    55.00   \n");
fprintf(stdout,"	 7. Candies         			    40.00   \n");
fprintf(stdout,"	 8. Dairy milk		                    50.00   \n");
fprintf(stdout,"	 9. Milky bar			            45.00   \n");
fprintf(stdout,"\n\n              *********************************************\n\n");
fprintf(stdout,"Enter the choice from FOOD COURT Menu \n\n");
fscanf(stdin, "%d", &response);
return response;
}

int main()

{
  int s,r;
  float p, x;
  int response;
  int sub;

  response = printMenu();
  printf("How many orders of item number %d would you like?\n", response);
  scanf("%d", &s);

  switch (response){
   case 1:
   printf("You have ordered %d order(s) of the Thums up\n");
   p=s * 60.00;
   printf("Net Ordered Amount:  %.2f\n\n", p);
   break;

   case 2:
   printf("You have ordered %d order(s) of the Sprite \n", s);
   p=s*60.00;
   printf("Net Ordered Amount:  %.2f\n\n", p);
   break;

   case 3:
   printf("You have ordered %d order(s) of the Coke\n", s);
   p=s*60.000;
   printf("Net Ordered Amount:  %.2f\n\n", p);
   break;

   case 4:
   printf("You have ordered %d order(s) of the Regular Cheeseburger\n", s);
   p=s*45;
   printf("Net Ordered Amount:  %.2f\n\n", p);
   break;

   case 5:
   printf("You have ordered %d order(s) of the Fish Sandwich\n", s);
   p=s*70;
   printf("Net Ordered Amount:  %.2f\n\n", p);
   break;

   case 6:
   printf("You have ordered %d order(s) of the French fries \n", s);
   p=s*55;
   printf("Net Ordered Amount:  %.2f\n\n", p);
   break;

   case 7:
   printf("You have ordered %d order(s) Candies \n", s);
   p=s*40;
   printf("Net Ordered Amount:  %.2f\n\n", p);
   break;

   case 8:
   printf("You have ordered %d order(s) Dairy Milk \n", s);
   p=s*50;
   printf("Net Ordered Amount:  %.2f\n\n", p);
   break;

   case 9:
   printf("You have ordered %d order(s) Milky bar\n", s);
   p=s*45;
   printf("Net Ordered Amount:  %.2f\n\n", p);
   break;


   default:
   printf(" \n\nError:  This is not on the menu. \n");
   break;
   }

printf("Do you have anything else\n1.Yes\n2.No\n\n");
scanf("%d",&r);
if(r==1)
{

}
else
printf("your Total Amount:%.2f\n\n",p);
x=p*1.13;
printf("Please pay  %.2f\n\n",x);
printf("Service Tax & VAT TAX of 1.13 was included.\n\n\n\n");
printf("                      Thank you for eating at FOOD COURT\n\n");
fprintf(stdout,"               *********************************************\n");
fprintf(stdout,"			        VISIT AGAIN		  \n ");
fprintf(stdout,"              *********************************************\n\n");
}
Posted
Updated 11-Aug-15 8:39am
v3
Comments
Member 11902249 11-Aug-15 14:11pm    
here there is a last block of if statement there i can want repeat my code plzzz help me
Sergey Alexandrovich Kryukov 11-Aug-15 15:58pm    
This is not your real problem. Your problem is not doing programming, but repeating stuff instead, hard-coding, and the like. Don't repeat yourself.
—SA
[no name] 14-Oct-15 4:51am    
Please try using fuctions

How about a loop, like a do/while loop.

do {

     // do some stuff, set r to some value

   } while (r == 1);
 
Share this answer
 
Quote:
How Can I Repeat My Code in the last if statement
It is impossible to copy a piece of code at a place which is inside the code copied because every times you copy the code, it create a new place where you must copy the code, it never end.

You have to find a way to execute your code more than once without duplicating it.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900