Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Develop a flowchart and then write a menu-driven C++ program that uses selection

ID: 3563830 • Letter: D

Question

Develop a flowchart and then write a menu-driven C++ program that uses selection and repetition constructs to solve the following problem. Upon execution of the program, the program displays a menu as shown below and the user is prompted to make a selection from the menu. The menu options are shown below. Help addIntegers subDoubles Quit Once the menu selection is made, the program validates acceptable inputs and proceeds with processing that selection as explained below. If the user selects h or H, a brief help screen will be displayed for the user. The help should tell the user how the program operates and what is needed from the user and how to terminate the program. Once the user viewed the help screen, striking any key will follow with the display of the menu again. If the user selects a or A, the user is prompted for two integers. The program computes and displays the two operands and the result (sum of the two integers) with appropriate labels. If the two integer data are 15 and 30, then the result is displayed as shown below. The sum of 15 + 30 = 45 Use a field width of 6, right justified for displayed information. Once the user observed the result, striking any key will follow with the display of the menu again. If the user selects d or D, the user is prompted for two doubles. The program computes and displays the two operands and the result (difference between the two doubles) with appropriate labels. If the two double data are 20 and 40, then the result is displayed as shown below. The difference of 20.00 40.00 = -20.00 Use appropriate formatting flags to show two digits after the decimal point. Once the user observed the result, striking any key will follow with the display of the menu again. If the user selects q or Q, the program displays a message of your choice before terminating the program. An example would be a message like: The program is terminated per user request

Explanation / Answer

#include
#include

class a
{
public:
   char disp()
   {
       char ans;
       clrscr();
       cout<<" "<<" Main Menu"<<" 1. Help [H/h]"<<" 2. addInteger [A/a]"<<" 3. subDouble [D/d]"<<" 4. Quit [Q/q]";
       cout<<" Enter your Choise";
       ans=getch();
       return ans;
   }
};

void main()
{
   char ans1;
   a o;
   aa: ans1=o.disp();

   if(ans1=='A' || ans1=='a')
   {
       int a,b,c;
       clrscr();
       cout<<" Enter 2 Integer values";
       cin>>a>>b;
       c=a+b;
       cout<<" Addition is "<    }

   if(ans1=='d' || ans1=='D')
   {
       double a,b,c;
       clrscr();
       cout<<" Enter 2 Double values";
       cin>>a>>b;
       c=a-b;
       cout<<" Substraction is "<    }

   if(ans1=='Q' || ans1=='q')
   {
       return;
   }

   if(ans1=='H' || ans1=='h')
   {
       clrscr();
       cout<<" : Help :";
       cout<<" 1. At the startup a menu is displayed to you.";
       cout<<" 2. To perform Addition of 2 Integers press either 'A' or 'a'";
       cout<<" 3. To Perform Substraction of 2 Doubles press either 'D' or 'd'";
       cout<<" 4. To go out of program press 'Q' or 'q'";
       cout<<" Press any key to return to Main Menu";

   }

   getch();
   goto aa;


}