Question: Use C++. Your program for this assignment should work almost like an ATM-like service, which will repeatedly display a menu of options and then serve

Use C++.

Your program for this assignment should work almost like an ATM-like service, which will repeatedly display a menu of options and then serve the user according to the option the user has selected until the user says he/she wants to quit the program. However, to practice the use of functions, we want to write three void functions in addition to the main function and use them in the main function for this task. The following is the suggested layout of your program:

 #include  using namespace std; 

//Define the displayMenu function in the following void displayMenu() { // Fill in your code for the displayMenu function

// ...}

//Define the checkLeapYear function in the following void checkLeapYear() { // Fill in your code for the checkLeapYear function

// ...}

//Define the checkPrime function in the following void checkPrime() { // Fill in your code for the checkPrime function

// ...}

//Define the main function in the following int main() { // Fill in your code for the main function

}

// calling checkLeapYear and checkPrime ... 

About the void function displayMenu: You should implement (define) thedisplayMenu function such that it can display the menu of options to the user whenisplayMenu is called.

About the void function checkLeapYear: You should implement (define) thecheckLeapYear function such that it can ask the user for an integer and then check to report whether it is a leap year when checkLeapYear is called.

About the void function checkPrime: You should implement (define) thecheckPrime function such that it can ask the user for an integer and then check to report whether it is a prime number when checkPrime is called.

About the main function: Like in Programming 4A, your main function should have a char type variable option to store the users choice of options. You should initialize the value of the variable to any character other than 'Q'. Your main function then should set up a while loop such that while the current choice character stored in the variable is not 'Q', the loop will do the following things in the body of the loop.

Call the displayMenu function to display a menu of three options L (to tell whether a given year is a leap year), P (to determine whether a given number is a prime number), and Q (to quit).

Prompt the user to choose one of the options by entering the corresponding character, and your program should then read the input character into the corresponding variable.

Use the switch statement (Section 4.14 in the textbook) to check the character stored in the variable option and serve the user accordingly.

o In case the character is 'L', call the checkLeapYear function appropriately to do the job.

o In case the character is 'P', call the checkPrime function to do the job.o In case the character is 'Q', display a message to thank the user for

using the program and say goodbye. o Default (in other words when it is none of the three cases above):

display a message to tell the user it is an unknown option that the program can not help.

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!