Answered step by step
Verified Expert Solution
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 decimal places.
Pseudocode:
Level
Display membership menu and ask for a selection
Ask how many months purchased
Calculate membership charges
Set formatting for decimal places
Display membership charges
Level
Display membership menu and ask for a selection
Ask how many months purchased
Output "How many months:
Input months
Calculate membership charges
If choice ADULTCHOICE Then
charges months ADULT
Else If choice CHILDCHOICE 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 ADULTCHOICE ; Menu choice for Adult membership
const int CHILDCHOICE ; Menu choice for Child membership
const int SENIORCHOICE ; Menu choice for Senior membership
const float ADULT ; Monthly membership fee for Adult membership
const float CHILD ; Monthly membership fee for Child membership
const float SENIOR ; 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 ADULTCHOICE
charges months ADULT;
else if choice CHILDCHOICE
charges months CHILD;
else
charges months SENIOR;
Set formatting for decimal places
cout fixed showpoint setprecision;
Display membership charges
cout
;
cout "Your membership charges are $ charges endl;
Indicate to OS successful termination of program
return ;
End main
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started