Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ include screenshots of input and output An application of the floor() function is rounding a value to a specific decimal point. The statement y

C++ include screenshots of input and output image text in transcribed
image text in transcribed
An application of the floor() function is rounding a value to a specific decimal point. The statement y - floor (x + 0.5); rounds the variable x to the nearest integer and assigns the result to y. The statement y - floor (x * 10.0 + 0.5)/10.0; rounds the variable x to the tenths place and assigns the result to y. The statement y - floor (x 100.0 + 0.5)/100.0; rounds the variable x to the hundredths place and assigns the result to y. Write a program that defines four functions to round a variable x various ways with the following function prototypes: a) int roundToInteger (double x); b) double roundToTenths (double x); c) double roundToHundredths (double x); d) double roundtoThousandths (double x); Use these functions to round the average of a sequence of numbers to the proper decimal point. Specifications: Prompt the user to enter the number of values to be averaged. Use this value to create a for() loop to read in a sequence of numbers. Calculate the average of the numbers, and pass the average into each of the functions to round the value to the required decimal points. Print the results to the screen with 4 values after the decimal point, as necessary. As an example, if you execute the program with the following underlined inputs, the output will be: -> main.o Enter Number of Values to be Averaged: 3 Enter a number: 1.299999 Enter a number: 4.5321 Enter a number: -2.3 The raw average is: ...to the nearest integer: ...to the tenths place: ...to the hundredths place: 1.1774 1 1.2000 1.1800 ...to the thousandths place: 1.1770

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

Students also viewed these Databases questions

Question

5. Describe the visual representations, or models, of communication

Answered: 1 week ago