Question: Please use the code template provided below Please use the template below before you start. Lab 6; Value-returning functions Problem: You will be have to

Please use the code template provided below
Please use the code template provided below Please use the template below
before you start. Lab 6; Value-returning functions Problem: You will be have
to round numbers very often so you decided to create your own
function round of 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
Please use the template below before you start.
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

Lab 6; Value-returning functions Problem: You will be have to round numbers very often so you decided to create your own function round of 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 decdig 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. Q se Once you have this program working you will modny it according to step 2. There are comments in the provided cpp file that indicate where you have to insert the prototype and define the function. The call to the function will be done in the statement where you do the rounding in maino. . Note: Do NOT remove or modify the statements that I use to test certain things in your program. Run my sample solution to know how your program must behave. Pay attention to the input and the output formats. Your solution must behave exactly like mine. Carefully analyze the following figure and use it as a reference to ensure you do the right things CAWINDOWS\system32\cmd.ee Enter the real number: 2.23128744 Enter number of digits: 5 The original number is 2.2312874400 The rounded number is 2.2312900 Press any key to continue . Test and compare your solution with mine for different values of the number and the number of digits to ensure they always produce the same outputs. Pay attention to the output format. Ensure your formulas do not use mixed data types. . -10: wrong variable names -10: wrong data types -10: no/too few comments -10: mixed data types in expression -15: didn't round the value off - 7: incorrect way to round the value off -30: didn't implement the required function -15: incorrect implementation of the function -10: incorrect function call -10: incorrect input format -5: incorrect output format -50: program doesn't compile -10: Late Puder sin and include into 1/ to be a vid pereter te // Include her the raries that your progress to colle using pee std; Ignore this 108 little function used for making tests inline void testconst chan expression, constekarstue. Int Line) SRET test restan" falted in Pelece SET . tine este w mia goes along with the above function...don't worry about it Adefine test (EPRESSION 1 (rides PRESSION, NE) // Insert here the prototype of the function here I int main() il Dectare variable welve. Y that holdsouble precision rat number 4 Declare variable desde the holes whole numbers 11 From the ver to enter the real number // Read from yoord the value entered by the user and assign it to // Prompt the war to Enter number of digits: 11 Read free key the value entered by the user and to este Round the real number to the winter of actual digits sellest assign the result telur // Format the evtovt to display the numbers in ad fermeten en decimal digita // Display on the screen, using 23 columns, the 11 The original under 18 value Il Format the output to display the numbers in the forest with the ruler of decimal digits pead pasa 1/ Display on the screen, using 3 columns, the message 11 The rounded number 1 // Incorrect date tre used for value // Incorrect dotate sed for man // Encorrect data type wieder systems 1/ BO NOT remove or modify the following statements Testing your sleer Lestivalue type: .. testteltyped.) testy type A include these tests are the function has been implemented testaba round of 129. 12343700,2) - 125.12 1.001 test round of 12.123854701 - 12.1298) 0.00 testost round offlin.607503, ) - 135.90765) 2.0) el systen return i > // Incorrect rounding to the decine digita // incorrect rounding to four decine digita Incorrect rounding to decine digits Il neorrect rounding to fin decal digits CRC:\WINDOWS\system32\cmd.exe Enter the real number: 23. 13457891235 Enter number of digits: 3 The original number is 23. 1345789124 The rounded number is 23. 13500 Press any key to continue fomet View Help 7 Include here the libraries that your program needs to compile using namespace std; I lgnore this; it's a little function used for making tests inline vold test(const chan expression, const chart file, Int line) cere "test" expression > testtype (value) - Type(1) test(typeiddi) - Type(i)): Include the tests ince the function has been implemented test(abs (rdel af (125 1234567, 2) 11.12 ) // Incorrect rounding to the decine digita // incorrect rounding to four decine digita Incorrect rounding to decine digits Il neorrect rounding to fin decal digits CRC:\WINDOWS\system32\cmd.exe Enter the real number: 23. 13457891235 Enter number of digits: 3 The original number is 23. 1345789124 The rounded number is 23. 13500 Press any key to continue fomet View Help 7 Include here the libraries that your program needs to compile using namespace std; I lgnore this; it's a little function used for making tests inline vold test(const chan expression, const chart file, Int line) cere "test" expression > testtype (value) - Type(1) test(typeiddi) - Type(i)): Include the tests ince the function has been implemented test(abs (rdel af (125 1234567, 2) 11.12 )

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!