Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in this c + + program how can i finish the int main step in order to display a menu for teh membership options and

in this c++ program how can i finish the int main step in order to display a menu for teh membership options and read the user's selection into the variable 'choice'
* Function Description:
* The function will first ask the user what type of membership they have,
* including error checking. Once the user has made a valid selection, it will
* then ask the user how many months they want to purchase. Finally, it will
* calculate and display the membership charges formatted to 2 decimal places.
*
* Pseudocode:
* Level 0
*-------
* Display membership menu and ask for a selection
* Ask how many months purchased
* Calculate membership charges
* Set formatting for 2 decimal places
* Display membership charges
* Level 1
*-------
* Display membership menu and ask for a selection
*
* Ask how many months purchased
* Output "How many months: "
* Input months
* Calculate membership charges
* If choice == ADULT_CHOICE Then
* charges = months * ADULT
* Else If choice == CHILD_CHOICE Then
* charges = months * CHILD
* Else
* charges = months * SENIOR
* End
* Display membership charges
* Output EOL, EOL
* Output "Your membership charges are $", charges, EOL
*******************************************************************************/
int main()
{
//Local constants
const int ADULT_CHOICE =1; //Menu choice for Adult membership
const int CHILD_CHOICE =2; //Menu choice for Child membership
const int SENIOR_CHOICE =3; //Menu choice for Senior membership
const float ADULT =40.00; //Monthly membership fee for Adult membership
const float CHILD =20.00; //Monthly membership fee for Child membership
const float SENIOR =30.00; //Monthly membership fee for Senior membership
//Local variables
int choice; //Menu choice of what type of membership user wants to purchase
int months; //Number of months user wishes to purchase membership
float charges; //Total membership charges
/******************* Begin main Function Executables **********************/
//Display membership menu and ask for a selection
//Ask how many months purchased
cout << "How many months: ";
cin >> months;
//Calculate membership charges
if (choice == ADULT_CHOICE)
charges = months * ADULT;
else if (choice == CHILD_CHOICE)
charges = months * CHILD;
else
charges = months * SENIOR;
//Set formatting for 2 decimal places
cout << fixed << showpoint << setprecision(2);
//Display membership charges
cout <<"
";
cout << "Your membership charges are $"<< charges << endl;
//Indicate to OS successful termination of program
return 0;
}//End main

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

Beyond Big Data Using Social MDM To Drive Deep Customer Insight

Authors: Martin Oberhofer, Eberhard Hechler

1st Edition

0133509796, 9780133509793

More Books

Students also viewed these Databases questions

Question

2. Speak in a firm but nonthreatening voice.

Answered: 1 week ago