Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Modify the following C + + program so that it uses functions and does error checking with the datathat is used in the calculations. int

Modify the following C++ program so that it uses functions and does error checking with the datathat is used in the calculations. int main() should be modified so that it calls the functions that are listed under "The Functions" headingbelow. int main() will no longer have any cout/cin statements to prompt the user for information, or anycalculations. Those will all be replaced by calling statements for functions.For each calculation, replace the calculation in main() with a calling statement for the correspondingfunction that performs the calculation. Make sure that the value returned from the function is saved inthe same variable that held the result of the calculation in Program 5.The error checking for this assignment is to make sure that invalid values cannot be used in thecalculations. The power value that is used when raising a number to a power and the value used tocalculate a factorial cannot be negative. Use a calling statement for the getNonNegativeValue() functionthat is described below as the replacement for the cout/cin combination that were used in Program 5.The divisor that is used in the division operation cannot be zero. Use a calling statement for the getNonZeroValue() function as the replacement for the cout/cin combination that was used in Program5.For addition, subtraction, multiplication, the dividend used in division, and the base value that is used when raising a number to a power, there is no real error checking to perform because any integer value can be used. Use a calling statement for the getValue() function as the replacement for the cout/cin combinations from the following c++ program example:
image text in transcribed

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_2

Step: 3

blur-text-image_3

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

Hands-On Database

Authors: Steve Conger

2nd Edition

0133024415, 978-0133024418

More Books

Students also viewed these Databases questions