Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ please An application of the floor) function is rounding a value to a specific decimal point. The statement yfloor(x 0.5) rounds the variable x

image text in transcribed
C++ please
An application of the floor) function is rounding a value to a specific decimal point. The statement yfloor(x 0.5) rounds the variable x to the nearest integer and assigns the result to y. The statement y floor (x10.0 0.5)/10.0; rounds the variable x to the tenths place and assigns the result to y. The statement yfloor(x100.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 hs (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 with4 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: 1 ...to the tenths place: ...to the hundredths place: 1.1800 1.1774 1.2000 ...to the thousandths place: 1.1770 Develop your I'O diagram and pseudocode, debug your code, and submit to the Grader Program

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

Learning MySQL Get A Handle On Your Data

Authors: Seyed M M Tahaghoghi

1st Edition

0596529465, 9780596529468

More Books

Students also viewed these Databases questions