Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can someone help me and explain the steps to this whole thing. I always have trouble doing code on my own :( 1 Lab fort.

image text in transcribed

Can someone help me and explain the steps to this whole thing. I always have trouble doing code on my own :(

1 Lab fort. will be modified d funct 3 PUT YOUR NAME HERE prototype 9 NRITEM PROTOTYPE FOR IHE tellFortal This prog ted by num child Convert o a positive integ 23 unChildren. 26 11 ha hildren 29 2 WRITE THE tel FUNCTION HEADER HERE 33 WRITE THE aoDY oF THE Run program to see how it works. What output do you get when you input the following values at e prompt 99 14 Step 3: Create a function that contains the fortune telling part of the code by doing the following On line 9 write the prototype for a unction named tellFortune that has two void teger parameters. On line 32 write the function header for the unction. Following that should be the body of the function, Move lines 22.26 of the program to the function Replace current lines 22.26 of main with a call to the te unction that passes Fortune it two arguments numYears and nunchildren. Step 4: Recompile and rerun the program. Enter -99 and 14 again. It should work the same as before. Step 5: If your professor asks you to do so, print the revised source code and the output of executing it several times, using a variety of inputs. LAB 6.3 Modularizing a Program with void Functions Step 1: Make a copy of the completed areas2.cpp program you revised in Lab 5.5 and place it in your Lab6 older. Name it areas3.cpp Step 2: Remove fortunes.cpp from the project and add the areas3.cpp program to the project. Step 3: Modularize the program by adding the following 4 functions. None of them have any parameters. id d iaplayMel void findSquareAreas void findCircleArea id findirii glear To do that you will need to carry out the following steps: Write prototypes for the four functions and place them above rain. Write function definitions (consisting of a function header and initially empty body) for the four functions and place them below rain Move the appropriate code out of main and into the body of each function. Move variable definitions in in for variables no longer in main to whatever functions now use those variables. They will be local variables in those functions. For example, need to define the side variable and will need find Squarearea findCircle Area to define the radius ariable. All of the functions thi compute areas will now need to define a variable named Move the definition for the named constant out of main and place it above the unction. In main, replace each block of removed code with a function call to the function now containing that block of code

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Transaction Processing

Authors: Philip M. Lewis, Arthur Bernstein, Michael Kifer

1st Edition

0201708728, 978-0201708721

More Books

Students also viewed these Databases questions