Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

For this part of the project you will do the following: (1) add input validation

ID: 3598125 • Letter: F

Question

For this part of the project you will do the following: (1) add input validation to the amount of coffee ordered, (2) modify the algorithm for determining types of cups needed to reduce the number of Shot cups used and (3) calculate the total price of the order based on the amount and type of coffee ordered. Use the table below to determine the price of the coffee.

Product               

Cost per Ounce

Plain Coffee

$0.13

Latte

$0.23

Macchiato

$0.25

Frappuccino

$0.28

Instructions:

Modify your Part 1 code to display the numbers of each type of cup needed for the order only if the amount of coffee ordered is greater than 0. Otherwise, just display a descriptive error message.

Modify your Part 1 code that determines the number of each type of cup to reduce the number of Shot cups used. Add functionality to your program so that a Regular (8 oz) cup will be used instead of multiple Shot (1 oz) cups if the number of Shot cups needed exceeds 3.

Calculate the total cost of the order including tax and display a bill for the coffee. See the Sample Output. The current sales tax rate is 7%. Use named constants for the sales tax rate and the base cost of each type of coffee.

Add a menu to offer the user a choice between the different types of coffee. The menu should be the first thing displayed when your program begins executing. The menu format should match the one in the Sample Output on page 2.

Validate the user’s menu choice. If the user enters any number other than 1, 2, 3 or 4 just display a descriptive error message. See Sample Output below for format.

the language is c++ and this how the output should look like.

Sample Output

Welcome to the World’s Best Coffee Shop

1 – Plain Coffee

2 – Latte

3 – Macchiato

4 – Frappuccino

Enter your choice: 1

Enter the number of ounces ordered: 13

Enter the name of the customer: Draco Malfoy

Draco Malfoy

Order: Plain Coffee 13 oz

Price of Coffee: $1.69

Sales Tax: $0.12

Total Amount Owed: $1.81

Cups Size                 Number Needed

--------------              ---------------------

    Venti                               0

    Grande                            0

    Regular                           2
    Shot                                0

Welcome to the World’s Best Coffee Shop

1 – Plain Coffee

2 – Latte

3 – Macchiato

4 – Frappuccino

Enter your choice: 6

6 is an invalid choice. Program ending.

Welcome to the World’s Best Coffee Shop

1 – Plain Coffee

2 – Latte

3 – Macchiato

4 – Frappuccino

Enter your choice: 3

Enter the number of ounces ordered: 0

0 is an invalid amount of coffee. Program ending.

Sample Output

Welcome to the World’s Best Coffee Shop

1 – Plain Coffee

2 – Latte

3 – Macchiato

4 – Frappuccino

Enter your choice: 1

Enter the number of ounces ordered: 13

Enter the name of the customer: Draco Malfoy

Draco Malfoy

Order: Plain Coffee 13 oz

Price of Coffee: $1.69

Sales Tax: $0.12

Total Amount Owed: $1.81

Cups Size                 Number Needed

--------------              ---------------------

    Venti                               0

    Grande                            0

    Regular                           2
    Shot                                0

Welcome to the World’s Best Coffee Shop

1 – Plain Coffee

2 – Latte

3 – Macchiato

4 – Frappuccino

Enter your choice: 6

6 is an invalid choice. Program ending.

Welcome to the World’s Best Coffee Shop

1 – Plain Coffee

2 – Latte

3 – Macchiato

4 – Frappuccino

Enter your choice: 3

Enter the number of ounces ordered: 0

0 is an invalid amount of coffee. Program ending.

Sample Output

Welcome to the World’s Best Coffee Shop

1 – Plain Coffee

2 – Latte

3 – Macchiato

4 – Frappuccino

Enter your choice: 1

Enter the number of ounces ordered: 13

Enter the name of the customer: Draco Malfoy

Draco Malfoy

Order: Plain Coffee 13 oz

Price of Coffee: $1.69

Sales Tax: $0.12

Total Amount Owed: $1.81

Cups Size                 Number Needed

--------------              ---------------------

    Venti                               0

    Grande                            0

    Regular                           2
    Shot                                0

Welcome to the World’s Best Coffee Shop

1 – Plain Coffee

2 – Latte

3 – Macchiato

4 – Frappuccino

Enter your choice: 6

6 is an invalid choice. Program ending.

Welcome to the World’s Best Coffee Shop

1 – Plain Coffee

2 – Latte

3 – Macchiato

4 – Frappuccino

Enter your choice: 3

Enter the number of ounces ordered: 0

0 is an invalid amount of coffee. Program ending.

Product               

Cost per Ounce

Plain Coffee

$0.13

Latte

$0.23

Macchiato

$0.25

Frappuccino

$0.28

Explanation / Answer

#include <iostream>

#include <iomanip>

using namespace std;

int main()

{

cout<<"Welcome to the World's Best Coffee Shop ";

cout<<"1 - Plain Coffee ";

cout<<"2 - Latte ";

cout<<"3 - Macchiato ";

cout<<"4 - Frappuccino ";

cout<<"Enter your choice: ";

string arr[4];

arr[0]="Plain Coffee";

arr[1]="Latte";

arr[2]="Macchiato";

arr[3]="Frappuccino";

float rate[4];

rate[0]=0.13;

rate[1]=0.23;

rate[2]=0.25;

rate[3]=0.28;

int choice;

cin>>choice;

cout<<endl;

if(choice<1 || choice>4)

{

cout<<choice<<" is an invalid choice. Program ending. ";

return 0;

}

cout<<"Enter the number of ounces ordered: ";

int ounces;

cin>>ounces;

cout<<endl;

if(ounces<1)

{

cout<<ounces<<" is an invalid amount of coffee.Program ending. ";

return 0;

}

cout<<"Enter the name of customer: ";

string name;

cin>>name;

cout<<endl;

cout<<name<<endl;

cout<<"Order: "<<arr[choice-1]<<" "<<ounces<<" oz ";

cout<<"Price of Coffee: $"<<ounces*rate[choice-1]<<endl;

cout<<"Sales Tax: $"<<fixed<<setprecision(2)<<0.07*ounces*rate[choice-1]<<endl;

cout<<"Total amount owed: $"<<1.07*ounces*rate[choice-1]<<endl;

int regs,shots;

regs=ounces/8;

if(ounces%8<=3)

{

shots=ounces%8;

}

else

{

regs++;

shots=0;

}

cout<<"Cups size needed Number ";

cout<<"---------------- ------- ";

cout<<"Venti 0 ";

cout<<"Grande 0 ";

cout<<"Regular "<<regs<<endl;

cout<<"Shots "<<shots<<endl;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote