Question

Write an app in C or C++ to calculate amount due for Food-to-Go restaurant. Food-to-Go sells...

Write an app in C or C++ to calculate amount due for Food-to-Go restaurant. Food-to-Go sells chicken sandwiches, chips, and drinks. Generate a function calculateAmountdue() to calculate for the total amount due.

Menu:

Sandwiches
(1) Chicken Sandwich ($5)
​(2) Hotdog ($4)​
(3) Pretzel ($3)

Chips
(1) Potato chips ($0.75)
​(2) Nachos ($3.50)​
(3) Popcorn ($2.50)

Drinks
(1) Soda ($2)​​
(2) Lemonade ($1.50)
​(3) Water ($1)
Example 1
Enter your selections (enter 0 if not ordering)
Enter sandwich selection: 2
How many: 2
Enter chip selection: 3
How many:1
Enter drink selection: 1
How many: 2

ITEMIZED
Sandwiches: $16
Chips: $2.50
Drinks: $4
TOTAL: $22.50
Example 2
Enter your selections (enter 0 if not ordering)
Enter sandwich selection: 0
How many: 0
Enter chip selection: 2
How many:2
Enter drink selection: 3
How many: 3

ITEMIZED
Sandwiches: $0
Chips: $7.00
Drinks: $3
TOTAL: $10.00
0 0
Add a comment Improve this question Transcribed image text
Answer #1

First we need to store the prices of items ,for which i have used array data structure.

Prices array for each array look like:

Index Element value
0 0 (if selection is 0 price is 0)
1 price of selection-1
2 price of selection-2
3 price of selection-2

Example:For sandwich the price array look like

Index Element value
0 0  
1 5
2 4
3 3

One more array of size 2 ,for each item is required to store the selection number and quantity.(taken from user)

index-0 stores selection-no

index-1 stores quantity

To find the totaldue amount,find dueamount for each item and sum them.

Dueamount for each element :price of Selected sub-item*quantity;

Example:For chips dueamount =chips[c[0]]*c[1] where c[0] has the selection-no,chips[c[0]] has the price of the selected sub-item and c[1] has the quantity.

Program in c:

#include <stdio.h>

//Declared all variables global,so that any function can access

//Arrays to store prices of items
float sandwiches[4]={0,5,4,3};
float chips[4]={0,0.75,3.50,2.50};
float drinks[4]={0,2,1.5,1};

//arrays to store selection-no and quantity
int s[2],c[2],d[2];


void calculateAmountdue()
{
float totaldue;
totaldue=sandwiches[s[0]]*s[1]+chips[c[0]]*c[1]+drinks[d[0]]*d[1];
  
printf("ITEMIZED\n");
printf("sandwiches:$%.2f\n",sandwiches[s[0]]*s[1]);
printf("Chips:$%.2f\n",chips[c[0]]*c[1]);
printf("Drinks:$%.2f\n",drinks[d[0]]*d[1]);
printf("Total:$%.2f",totaldue);

  
}

int main()
{
  
printf("Enter your selections(Enter 0 if not ordering)\n");
  
//selection of sandwiches
printf("Enter sandwich selection:");
scanf("%d",&s[0]);
printf("How many:");
scanf("%d",&s[1]);

//selection of chips
printf("Enter chips selection:");
scanf("%d",&c[0]);
printf("How many:");
scanf("%d",&c[1]);

  
//selection of drinks
printf("Enter drinks selection:");
scanf("%d",&d[0]);
printf("How many:");
scanf("%d",&d[1]);

  
calculateAmountdue();
return 0;
}

Add a comment
Know the answer?
Add Answer to:
Write an app in C or C++ to calculate amount due for Food-to-Go restaurant. Food-to-Go sells...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Overview JAVA LANGUAGE PROBLEM: The owner of a restaurant wants a program to manage online orders...

    Overview JAVA LANGUAGE PROBLEM: The owner of a restaurant wants a program to manage online orders that come in. This program will require multiple classes. Summary class, customer class, order class and the driver class. Summary class This class will keep track of the cost of the order and output a summary, which includes the total for the order. The methods in this class are static. There are no instance variables, and instead uses an Order object that is passed...

  • Jacques and his friend go out for lunch to a nearby food court. Jacques is trying...

    Jacques and his friend go out for lunch to a nearby food court. Jacques is trying to decide between ordering a burger or a sandwich. Which of the following factors will directly affect his decision? Check all that apply. The friend's recommendations The friend's budget The expected benefits of the two options The color of his friend's car The relative prices of burgers and sandwiches Suppose that a glass of apple juice at Jacques's gym cafeteria costs as much as...

  • For this assignment, you will need to go to a grocery store and find 1 food...

    For this assignment, you will need to go to a grocery store and find 1 food and drink that has been enriched with 1 or more vitamins/minerals AND 1 food and drink that has been fortified. For each of the two foods and drinks you select, explain in full sentences the following; 1. Name of two Foods and Drinks you select, one with 1 or more vitamins/ minerals AND 1 food and drink that has been fortilifed. 2. Whether the...

  • OPRE 3310: Homswork Assignment 3 Due on March 3- 2020 3. points) Suppose you plan to...

    OPRE 3310: Homswork Assignment 3 Due on March 3- 2020 3. points) Suppose you plan to go out for a picnic during spring break. You plan to bring sandwiches, fruits, and drinks. But you only have one pic ches, Truits, and drinks. But you only have one picnic basket that can only hold a certain capacity. Each of the items has a value and a size, and you cannot hold di your items in the basket. The picnic basket can...

  • Problem 2: Point of Sale System The McDowell Restaurant chain has asked you to write a...

    Problem 2: Point of Sale System The McDowell Restaurant chain has asked you to write a menu program for their new Fast-food service machines. Your program already prints the following menu like this: ********************************************************************** McDowell’s Restaurant ********************************************************************** Make your selection from the menu below: 1. Regular Hamburger $1.50 2. Regular Cheeseburger $1.75 3. Fish Sandwich $2.50 4. Half-pounder with cheese $2.75 5. French Fries $0.99 6. Large Soft Drink $1.25 *********************************************************************** Select 1, 2, 3, 4, 5, or 6 -----...

  • Write a program in Java that simulates a vending machine: The vending machine sells three types...

    Write a program in Java that simulates a vending machine: The vending machine sells three types of food: 1) Potato chips $1.25; 2) Cookies $0.85; 3) Candies $0.95. The program will prompt for the buyer to enter the amount in quarters (25 cents), dimes (10 cents), and nickels (5 cents). The program will then present a selection menu for the foods and prompt the buyer to enter the amount of quarters, dimes and nickels. The machine would then proceed to...

  • Programming Language is Python Need it to look just like the sample output. pls and ty!!...

    Programming Language is Python Need it to look just like the sample output. pls and ty!! Design your solution: 1. Main menu: Create a main user menu to display the main options to the user. User have the option to choose between 1 and 4. The program will display an error message if user option is not within the valid selection (less than 1 and greater than 4). Think about using a conditional structure to serve the user choice. Invalid...

  • Brain Food, Anyone? You and your classmates are about to go into the food business. Having spent many hours in the...

    Brain Food, Anyone? You and your classmates are about to go into the food business. Having spent many hours in the library without food or drink, you have received permission to operate a food cart in the lobby outside the library as long as you take re- sponsibility for keeping the area clean. You plan to provide bottled water, juices, and milk, as well as fruit, muffins, and trail mix. You will also offer gran- ola that can be purchased...

  • Please write this code in JAVA lang., thank you! Your spouse's cousin's nephew's dog's trainer's ...

    Please write this code in JAVA lang., thank you! Your spouse's cousin's nephew's dog's trainer's best friend owns a restaurant. That person is very bad at math and recently discovered that most customers have been significantly undercharged for meals. You have been approached to create a computer program that will accurately calculate bills for each customer. Kids, under 5, eat free. Teens and seniors get a 25% discount. Also, Food and beverage is taxed at 5%. No tax for anything...

  • Please write this code in JAVA lang., thank you! Your spouse's cousin's nephew's dog's trainer's best...

    Please write this code in JAVA lang., thank you! Your spouse's cousin's nephew's dog's trainer's best friend owns a restaurant. That person is very bad at math and recently discovered that most customers have been significantly undercharged for meals. You have been approached to create a computer program that will accurately calculate bills for each customer. Kids, under 5, eat free. Teens and seniors get a 25% discount. Also, Food and beverage is taxed at 5%. No tax for anything...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT