Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

[C++][MODIFY][GIVEN CODE] the Falafel program to do the following: 1) Create a counter for each type of item sold (Falafels, Sodas, Extras). 2) Use a

[C++][MODIFY][GIVEN CODE] the Falafel program to do the following:

1) Create a counter for each type of item sold (Falafels, Sodas, Extras). 2) Use a constant (const in C++, or #define in C) to define the tax rate. 3) When the 'T' key is pressed for the total, display the count and name for each item, the subtotal for all items, compute tax at 8.7%, display the amount of tax, and the final total for all items plus the tax. 4) Each display must show two digits past the decimal point for the subtotal, tax and total.

5) The program must process unexpected or illegal inputs. If the user enters a menu selection that is invalid, an error message must be displayed.

 #include  #include  void DisplayMenu(); // display the menu using namespace std; int main(int argc, char* argv[]) { double total = 0.00; double price; char selection; do { DisplayMenu(); price = 0; cout << "Make your selection (FSXT): "; cin >> selection; switch ( toupper(selection) ) { case 'F': price = 5.15; break; case 'S': price = 2.24; break; case 'X': price = 1.57; break; case 'T': break; default: cout << "Illegal selection, try again." << endl; } total += price; } while (selection != 'T' && selection != 't'); cout << "The total is $" << total << endl; return 0; } void DisplayMenu() { cout << endl; // blank line before start of menu cout << "F = falafel $5.15" << endl; cout << "S = soda $2.24" << endl; cout << "X = extras $1.57" << endl; cout << "T = total" << endl; } 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essential Data Protection For Estate Agencies In Singapore 2024

Authors: Yang Yen Thaw Yt

1st Edition

B0CQK79WD3, 979-8872095392

More Books

Students also viewed these Databases questions