Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2) PE 05a 02 (Rounding to Decimals) Rounding floating-point numbers to a specific decimal place using the floor function can be accomplished by scaling the

image text in transcribed

2) PE 05a 02 (Rounding to Decimals) Rounding floating-point numbers to a specific decimal place using the floor function can be accomplished by scaling the function by 10 or 100 to round to the nearest tenths or hundredths, respectively. The statements below demonstrate how the floor function can be scaled to perform each rounding operation. y-floor( x * 10 + ?.5 ) / 1.0; // rounds to tenths y-floor( x * 100 + ?.5 ) / 100.0; // rounds to hundredths Modify the statements above to create three functions that round a floating-point number to the nearest tenths, hundredths, and thousandths. Each function that you create should receive a double data type as the argument and return a double data type Test your functions using a for loop that varies the control variable from 0.1 to 10 in increments of 0.3674. Print the loop count, original umber, and eack of the three rounded nmonbers. The list should be in a tabular format and include the default precision for floating- point numbers. Your program should also include a title for the table. Use a single if statement inside the for loop to print only the values at loop iterations 5, 10, and 15 as illustrated below i Original Tenths Hundredths Thousandths 5 1.5696001.600000 1.5780001.570000 10 3.406600 3.4000003.410000 3.407000 15 5.243600 5.200000 5.240000 5.24480e

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

Flash XML Applications Use AS2 And AS3 To Create Photo Galleries Menus And Databases

Authors: Joachim Schnier

1st Edition

0240809173, 978-0240809175

More Books

Students also viewed these Databases questions