Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need done by tonight!! Lab 6: Value-returning functions Problem: You will be have to round numbers very often so you decided to create your own

Need done by tonight!! image text in transcribed
image text in transcribed
image text in transcribed
Lab 6: Value-returning functions Problem: You will be have to round numbers very often so you decided to create your own function round off that will receive the number to be rounded and the number of decimal digits that the number should be rounded to and will return the value rounded to the specified number of decimal digits. You need to create a program to test the function. It will ask the user to enter the double precision real number to be rounded and a whole number indicating the number of decimal digits. It will then display the original number with ten digits and the rounded value (also a double precision real number) with the number of digits specified by the user plus 2 more. This assignment will be completed in two steps: 1) First you will implement the algorithm shown below in which the rounding will be done in main() 2) Once you have this working you will need to modify your solution so you: Declare the prototype of the function above main() Call the function in main() to do the rounding Define the function below main() I Your task: implement in C# the algorithm solution shown below for the first step, Algorithm solution (in pseudocode): To solve this problem your program must perform the following tasks: 1. 5 points. Declare variable value, valuero that hold double precision real numbers 2. 5 points. Declare variable decdig that holds whole numbers 3. 8 points. Prompt the user to "Enter the real number: 4. 8 points. Read from keyboard the value entered by the user and assign it to value 5. 8 points. Prompt the user to "Enter number of digits: 6. 8 points. Read from keyboard the value entered by the user and assign it to deedig 7. 24 points. Round the real number to the number of decimal digits specified and assign the result to valuero 8. 8 points. Format the output to display the numbers in fixed format with ten decimal digits 9. 8 points. Display on the screen, using 23 columns, the message "The original number is", value 10. 10 points, Format the output to display the numbers in fixed format with the number of decimal digits specified plus 2 11. 8 points. Display on the screen, using 23 columns, the message "The rounded number is", valuero The program must compile without errors or warnings. ile ort Format View Help // Include here the libraries that your program needs to compile using namespace std; // Ignore this; it's a little function used for making tests Inline void test(const char" expression, const char file, int line) { cerr

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

Excel As Your Database

Authors: Paul Cornell

1st Edition

1590597516, 978-1590597514

More Books

Students also viewed these Databases questions