Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The errors.cpp program contains several syntax and logical errors. Fix all the errors and submit the corrected source file. Once all the errors are fixed,

The errors.cpp program contains several syntax and logical errors. Fix all the errors and submit the corrected source file. Once all the errors are fixed, you should be able to reproduce the program output similar to what is (from three separate executions) listed below:

Example of expected output.

Enter hours worked: 45 The net pay is $562.50 Exiting...

Example of expected output.

Enter hours worked: 40 The net pay is $500.00 Exiting...

Example of expected output.

Enter hours worked: 33.5 The net pay is $418.75 Exiting...

Note: In order to get the ideal "currency" output (with exactly 2 decimal places), you need formatted output. If you would like to look into formatted output, the information is available in the book, and you are encouraged to take a look (pay special attention to the fixed and setprecision stream manipulators).

Write a Math Wizard program, call it spHWmathWizard.cpp, that will prompt the user three times for a five-digit integer, provide two of its own five-digit integers and predict the sum of the all of the five-digit integers after the user inputs the only first of the integers. The program should display a message explaining its purpose prior to prompting the user for a number. The following is an example of the output such a program might generate.

Example of expected output.

I am a Math Wizard program. I can predict the sum of five (5) five-digit positive integers after seeing only the first of the five numbers. Please enter your first five-digit positive integer: 47923 I predict the sum will be 247921. Please enter your second five-digit positive integer: 38573 I will provide the third five-digit positive integer: 61426 Please enter the fourth five-digit positive integer: 25953 I will provide the final five-digit positive integer: 74046 47923 + 38573 + 61426 + 25953 + 74046 = 247921 I am a Math Wizard.

The trick to generating the correct sum is to first subtract 2 from the number entered by the user and then add 200000 to the result. The rest of the trick is generating the correct five-digit numbers to display to the user. To generate the correct third five-digit integer, subtract the second number, provided by the user, from 99999. To generate the last number, subtract the fourth five-digit integer from 99999.

What causes the Math Wizard to stumble? In other words, what causes the program to not perform to specifications? Place your answer in a comment following the main function.

The division algorithm states that given two integers [a] and [d] , with [d ot=0] , there exists unique integers [q] and [r] such that [a = qd+r] and [0 \leq r < |d|] , where [|d|] denotes the absolute value of [d] . The integer [q] is the quotient, [r] is the remainder, [d] is the divisor, and [a] is the dividend. You are to write a program named spHWdivision.cpp that will prompt the user for a dividend and divisor and then display the division algorithm's results in the sentence format below (four separate examples are shown): If a = 17 and d = 3, then q = 5 and r = 2, since 17 = (5)(3) + 2. If a = 17 and d = -3, then q = -5 and r = 2, since 17 = (-5)(-3) + 2. If a = -17 and d = 3, then q = -6 and r = 1, since -17 = (-6)(3) + 1. If a = -17 and d = -3, then q = 6 and r = 1, since -17 = (6)(-3) + 1.

In testing your program, consider the four possible combinations of positive and negative dividends and divisors (as shown above).

The C++ operators for integer division do not conform to the division algorithm. Explain in output displayed to the user of the program when to expect results that disagree with the division algorithm. The program should not attempt to resolve this issue.

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

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

3rd Edition

978-1119907466

More Books

Students also viewed these Databases questions

Question

What is the basis for Security Concerns in Cloud Computing?

Answered: 1 week ago

Question

Describe the three main Cloud Computing Environments.

Answered: 1 week ago