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 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
![ChiliToGoProfit.java
1 import java.util.Scanner;
2 class ChiliToGoProfit
3 {
4 public static void main(String[] args) {
// Modify the code below.
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34}
35
final double ADULT_PRICE = 7;
CHILD_PRICE = 4;
final double
final double ADULT_COST = 4.35;
final double CHILD_COST = 3.10;
int adultMeals;
int childMeals;
double totalAdult, totalChild, grandTotal;
double adultProfit, child Profit, totalProfit;
Scanner input = new Scanner(System.in);
System.out.print("Enter number of adult meals ordered >> ");
adultMeals = input.nextInt ();
System.out.print("Enter number of child meals ordered >> ");
childMeals = input.nextInt();
totalAdult = adultMeals * ADULT_PRICE;
totalChild = childMeals * CHILD_PRICE;
grandTotal = totalAdult + totalChild;
adultProfit = ADULT_PRICE - ADULT_COST;
childProfit = CHILD_PRICE - CHILD_COST;
totalProfit = adultProfit + childProfit;
System.out.println(adultMeals + "adult meals were ordered at " + ADULT_PRICE + " each.");
Total is " + totalAdult);
11
System.out.println(childMeals + child meals were ordered at " + CHILD_PRICE + " each.");
Total is " + totalChild);
System.out.println("
System.out.println("
System.out.println("Grand
System.out.println("
System.out.println("
System.out.println("Total
total for all meals is " + grandTotal);
Adult profit is " + adultProfit);
Child profit is " + childProfit);
profit is " + totalProfit);](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fd5b13c2f-d38b-4c7e-8927-0b5918885d4c%2F15419a2b-e4cf-4eff-98f9-ad909ac50ec5%2Fuq1hh2cq_processed.png&w=3840&q=75)

Modified CODE is given below
Inline comments are given for your explanation
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images









