In the ChiliToGo program in Exercise 12, the costs to produce an adult meal and a child’s meal are $4.35 and $3.10, respectively. Adult meals are sold for $7.00 and children's meals are sold for $4.00. Modify the ChiliToGo program to display the total profit for each type of meal as well as the grand total profit. An example of the program is shown below: Enter number of adult meals ordered >> 10 Enter number of child meals ordered >> 5 10 adult meals were ordered at 7.0 each. Total is 70.0 5 child meals were ordered at 4.0 each. Total is 20.0 Grand total for all meals is 90.0 Profits: Adult profit is 26.5 Child profit is 4.5 Total profit is 31.0
Max Function
Statistical function is of many categories. One of them is a MAX function. The MAX function returns the largest value from the list of arguments passed to it. MAX function always ignores the empty cells when performing the calculation.
Power Function
A power function is a type of single-term function. Its definition states that it is a variable containing a base value raised to a constant value acting as an exponent. This variable may also have a coefficient. For instance, the area of a circle can be given as:
In the ChiliToGo
An example of the program is shown below:
Enter number of adult meals ordered >> 10 Enter number of child meals ordered >> 5 10 adult meals were ordered at 7.0 each. Total is 70.0 5 child meals were ordered at 4.0 each. Total is 20.0 Grand total for all meals is 90.0 Profits: Adult profit is 26.5 Child profit is 4.5 Total profit is 31.0
Algorithm for ChiliToGo program:
Define constants for the cost and price of adult and child meals.
Read the number of adult and child meals ordered by the user.
Calculate the total cost and revenue for each type of meal.
a. For adult meals:
i. Calculate the total cost as the product of the number of adult meals ordered and the cost per meal.
ii. Calculate the total revenue as the product of the number of adult meals ordered and the price per meal.
b. For child meals:
i. Calculate the total cost as the product of the number of child meals ordered and the cost per meal.
ii. Calculate the total revenue as the product of the number of child meals ordered and the price per meal.
Calculate the profit for each type of meal.
a. For adult meals, subtract the total cost from the total revenue.
b. For child meals, subtract the total cost from the total revenue.
Calculate the grand total for all meals.
a. Sum the total cost of both types of meals.
b. Sum the total revenue of both types of meals.
c. Calculate the grand total profit as the difference between the total revenue and total cost.
Display the results.
a. Show the number of adult and child meals ordered and the total revenue for each type of meal.
b. Show the grand total revenue for all meals.
c. Show the profit for each type of meal. d. Show the grand total profit.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images