Question: WOULD SOMEONE HELP ME WITH THIS CODE I WROTE IT BUT COULD NOT ABLE TO RUN IT BUT I THINK I MADE A MISTAKE C++

WOULD SOMEONE HELP ME WITH THIS CODE I WROTE IT BUT COULD NOT ABLE TO RUN IT

BUT I THINK I MADE A MISTAKE

C++ AND ALSO INCLUDES COMMENTS

#include #include using namespace std;

// Define named constants for the cost per ounce of each product and sales tax rate const double BANANA_COST = 0.62; const double STRAWBERRY_COST = 0.60; const double MANGO_COST = 0.48; const double BLUEBERRY_COST = 0.57; const double SALES_TAX_RATE = 0.045;

int main() { // Declare variables for the smoothie type, size, and cost char smoothie_type; int smoothie_size; double cost = 0.0; // Display the smoothie type menu and get user input cout << "Select smoothie type:" << endl; cout << "B - Banana" << endl; cout << "S - Strawberry" << endl; cout << "M - Mango" << endl; cout << "L - Blueberry" << endl; cin >> smoothie_type; // Determine the cost per ounce based on the smoothie type switch (smoothie_type) { case 'B': cost = BANANA_COST; break; case 'S': cost = STRAWBERRY_COST; break; case 'M': cost = MANGO_COST; break; case 'L': cost = BLUEBERRY_COST; break; default: cout << "Invalid smoothie type" << endl; return 0; } // Display the smoothie size menu and get user input cout << "Select smoothie size:" << endl; cout << "1 - Small (20 oz)" << endl; cout << "2 - Medium (32 oz)" << endl; cout << "3 - Large (40 oz)" << endl; cin >> smoothie_size; // Calculate the cost of the smoothie based on size and cost per ounce switch (smoothie_size) { case 1: cost *= 20; break; case 2: cost *= 32; break; case 3: cost *= 40; break; default: cout << "Invalid smoothie size" << endl; return 0; } // Calculate the total cost including sales tax double total_cost = cost * (1 + SALES_TAX_RATE); // Display the bill for the smoothie cout << fixed << setprecision(2); cout << "Smoothie Type: "; switch (smoothie_type) { case 'B': cout << "Banana" << endl; break; case 'S': cout << "Strawberry" << endl; break; case 'M': cout << "Mango" << endl; break; case 'L': cout << "Blueberry" << endl; break; } cout << "Smoothie Size: "; switch (smoothie_size) { case 1: cout << "Small (20 oz)" << endl; break; case 2: cout << "Medium (32 oz)" << endl; break; case 3: cout << "Large (40 oz)" << endl; break; } cout << "Cost: $" << cost << endl; cout << "Sales Tax: $" << cost * SALES_TAX_RATE << endl; cout << "Total Cost: $" << total_cost << endl; return 0

INSTRUCTIONS

You have been hired by a local smoothie shop to write a program that will calculate the cost of a smoothie order. The shop sells four types of smoothies in three different sizes: Small (20 oz), Medium (32 oz) and Large (40 oz). Your program should use a menu for the type of smoothie and a second menu for the smoothie size. Calculate the total cost of the order including tax and display a bill for the smoothie. See the Sample Output. The sales tax rate is 4.5%. Use named constants to hold the cost per ounce of each of the products and the sales tax rate. Use the constants in your calculations and wherever else they are appropriate in your program.

Product Cost per Ounce Banana $0.62

Strawberry $0.60

Mango $0.48

Blueberry $0.57

Calculate the subtotal: cost of the smoothie (smoothie type * size in ounces), sales tax (subtotal * tax rate), and total cost of the order (subtotal + tax rate) and display a bill for the Tea.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!