Question
1. Declare a global constant named PI equal to 3.141592; 2. Declare variables named base, height, radiusa, radiusb, rec_area, and elli_area that hold real numbers.
1. Declare a global constant named PI equal to 3.141592;
2. Declare variables named base, height, radiusa, radiusb, rec_area, and elli_area that hold real numbers.
3. Print on the screen For the rectangle
4. Call void function getData(base, height) that gets two lengths from the keyboard and returns them to main( ).
5. Print on the screen For the ellipse
6. Call void function getData(radiusa, radiusb) that gets two lengths from the keyboard and returns them to main( ).
7. Calculate the area of the rectangle and store the result in rec_area.
8. Calculate the area of the ellipse and store the result in elli_area.
9. Call void function printData(rec_area, elli_area) that receives the two areas and prints on the screen the message: "The area of the rectangle is ", rec_area "The area of the ellipse is ", elli_area Function getData(rpar1, rpar2 ) must: 1. Prompt the user to "Please enter two lengths: "
2. Get both values from the keyboard and store them in rpar1 and rpar2. Note: rpar1 and rpar2 are reference parameters. Function printData(vpar1, vpar2) must: 1. Format the output to display the numbers in fixed format with one decimal digit.
2. Print the message on the screen. Note: vpar1 and vpar2 are value parameters. IMPORTANT: See examples of void functions in the textbook and on my web page to get a starting point. ------------------------------------------------------------------------------------------------------------------------ Part B (16 points) Modify the above program so that the areas are calculated by a couple of value-returning functions named area_rectangle( ) and area_ellipse( ). Each of these functions must call getData() to get the values, calculate the area, and return it through the functions value. IMPORTANT: steps 3 through 8 specified in Part A should be replaced by a couple of statements where these functions are called. ------------------------------------------------------------------------------------------------------------------------ Part C (5 points) Modify the above program so that: printData() sends the output to an output file named output7.txt. Note: The file must be opened in main() and passed to printData() as an argument. Dont forget to close it at the end of your program.
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