Background: You are an entry-level programmer with the ACME Development Firm. Yo
ID: 3639462 • Letter: B
Question
Background:You are an entry-level programmer with the ACME Development Firm. Your boss has selected you and some other developers to plan a new ice cream application for an up and coming ice cream shop (you decide the name of the ice cream shop).
In general, the application you are planning takes the customer’s order and the program estimates the cost of their sundae order while standing in line.
Calculations Required:
The ice cream has 2 flavors of sundaes. You can only select one type of sundae.
The costs are:
• Hot Fudge: $1.00
• Caramel: $.75
The sundaes come in 2 sizes:
• Small: $1.00
• Large: $2.00
The sundaes have a few toppings that can be added but you do not have to have any toppings. You can add any combination of toppings.
The toppings are: sprinkles, nuts, and gummi bears.
The cost is: for one topping, $.50. For 2 or more toppings, they cost $.40 each.
Your program must calculate how much each sundae will cost for the customer.
Be sure to use modularization in your program.
You can order multiple sundaes, but they are any flavor/size/toppings.
Display the cost for one sundae and the add-on cost for one sundae. Then display the total cost overall for all sundaes ordered. Format your output appropriately.
In an output label, develop a message that identifies the number, sundae flavor and size the person ordered. (Example: You ordered 2 small hot fudge sundaes which will cost you $x.xx (where x.xx is the cost for all sundaes ordered)).
Explanation / Answer
float cost[3][3],amount = 0 ; int i,a,b,n; int hfcnt=0,caramelcnt =0; //define costs cost[1][1] = 1; // cost of hot fudge cost[1][2] = .75; //cost of caramel cost[2][1] = 1; // cost of small size sundae cost[2][2] = 2; // cost of large size sundae read(N); // no of ice creams loop from i = 1 to N do{ print(choose flavor:) 1. hot fudge 2. caramel scan (a); if a=1 hfcnt++; else caramelcnt++; amount = amount + c[1][a]; if (a == 1) amount += choose size: 1 small, 2 large scan(a); amount = amount+c[2][a] no of toppings: read(n); if n == 1 amount = amount + 0.5 else amount = amount + 0.4 *n; end d0 print("You ordered %d small hot fudge sundaes and %d which will cost you $4.2f%",hfcnt,caramelcnt,amount); }
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.