- Step 2 Add A Do While Loop To The Program So That The User Can Repeatedly Display The Menu Make A Choice And Have The 1 (61.77 KiB) Viewed 40 times
Step 2: Add a do-while loop to the program so that the user can repeatedly display the menu, make a choice, and have the
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
Step 2: Add a do-while loop to the program so that the user can repeatedly display the menu, make a choice, and have the
Step 2: Add a do-while loop to the program so that the user can repeatedly display the menu, make a choice, and have the appropriate steps for that choice carried out. The loop should continue iterating until the user enters 4 for the menu choice. Have the program print several blank lines after each case is carried out before the menu displays again. Step 3: Modularize the program by adding the following 4 functions. None of them have any parameters. void displayMenu() ● void findsquareArea () void findCircleArea () void findTriangleArea () To do that you will need to carry out the following steps: Write prototypes for the four functions and place them above main. Write function definitions (consisting of a function header and initially empty body) for the four functions and place them below main. Move the appropriate code out of main and into the body of each function. Move variable definitions in main for variables no longer in main to whatever functions now use those variables. They will be local variables in those functions. For example, findSquareArea will need to define the side variable and findCircleArea will need to define the radius variable. All of the functions that compute areas will now need to define a variable named area. Move the definition for the named constant PI out of main and place it above the main function. In main, replace each block of removed code with a function call to the function now containing that block of code. Step 4: Compile the code, fixing any errors until it compiles without errors. Then test it. Make sure it runs correctly for all menu choices. Step 5: Print the revised source code and the output of executing it, selecting each menu choice at least once. You should submit a printed free of errors program.