Question: 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

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!