Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Programming The Perl DBI Database Programming With Perl

Authors: Tim Bunce, Alligator Descartes

1st Edition

1565926994, 978-1565926998

More Books

Students also viewed these Databases questions

Question

outline some of the current issues facing HR managers

Answered: 1 week ago