The ice cream has 2 flavors of sundaes. You can only select one type of sundae.
ID: 3639670 • Letter: T
Question
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
Here is C++ program for it ..some Guidelines:
1) Get input .. how many ice creams you want ? .. flavour? size ? toppings(one or many)
2)make 8 cases depending upon inputs (if else if ladder)
3) Apply a Loop on above steps ..for the no. of ice creams needed(like one wants 2 ice creams then loop will execute 2 times)
4) sum= sum+cost ..which adds up the costs after each iteration ! ..
5)Finally , sum is printed ..after the loops is over
#include<iostream>
using namespace std;
int main()
{
int n;
cout<<"Enter how many ice creams you want:";
cin>>n;
float sum=0.0;
for(int i=0;i<n;i++) {
float flavour,size,tops,cost;
cout<<"Enter flavour :Press 1 for hotfuge 2 for caramel ";
cin>>flavour;
cout<<"Enter Size of cone :Press 1 for small or 2 for large:";
cin>>size;
cout<<"Choose topping : Press 1 for single topping 2 for two or more toppings ";
cin>>tops;
int t;
if(tops==2)
{
cout<<"Enter no. of toppings";
cin>>t;
}
if(flavour==1&&size==1&&tops==1)
cost=2.50;
else if(flavour==1&&size==1&&tops==2)
cost=2.00+.4*t;
else if(flavour==1&&size==2&&tops==1)
cost=3.50;
else if(flavour==1&&size==2&&tops==2)
cost=3.00+.4*t;
else if(flavour==2&&size==1&&tops==1)
cost=2.25;
else if(flavour==2&&size==2&&tops==1)
cost=3.25;
else if(flavour==2&&size==1&&tops==2)
cost=1.75+.4*t;
else if(flavour==2&&size==2&&tops==2)
cost=2.75+.4*t;
sum=sum+cost; } c
cout<<" total cost:$"<<sum;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.