Question: in c++ Write a program that calculates the ceiling of a decimal number Basically the ceiling of any decimal number x, is the nearest integer

in c++

Write a program that calculates the ceiling of a decimal number

Basically the ceiling of any decimal number x, is the nearest integer greater than or equal to to x.

For example, the ceiling of 2.4 is 3. The ceiling of 4.2 is 5. The ceiling of -23.1 is -23. The ceiling of 9.0 is 9.

Requirements

1) You must implement a function to calculate the ceiling (you cannot use C++'s ceiling function). Name it something like ceilingAndError.

2) The program will ask the user to input a number (let's call this variable userInput)

3) The number will be passed to ceilingAndError by Reference

4) The function should change the userInput variable to the nearest integer number greater than or equal to the original value of userInput that was inputted by the user. Therefore if the user inputted 4.3 into the variable userInput, after the function runs userInput will have the value 5.0. (note in the negative case if the user enters -4.3 the ceiling is actually -4, think about how you might do this)

5) The function should return how much the value was changed by, i.e., the difference between the new value of userInput and the old value of userInput. SO if the user inputted 4.3 the function will return a value equal to 5.0-4.3= .7

6) The program should define the function prototype above main and the function definition after main

7) All the program input and output should occur in main

8) The function comments must have a pre condition and post condition both at the function prototype and the function definition

9) All the rest of the code should include comments too

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!