Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

For this assignment, fill in the blanks of a pre-written program with calls to v

ID: 3529850 • Letter: F

Question

For this assignment, fill in the blanks of a pre-written program with calls to various functions.

The pre-written program can be foundhere.

This program will test the effect of rounding dollar amounts to the nearest $10 rather than keeping track of exact amounts. It has been determined that if the difference between the results of the two methods (keeping track of exact values and keeping track of rounded values) is less than 2%, then it would be cost effective for a company to round rather than balance to the penny.

The program will accept dollar amounts from the user until 0 is entered. Each exact dollar amount is then rounded to the nearest $10 value. The exact and rounded amounts are then used to keep track of:

After the user has entered an exact amount of 0, the sum, average, and standard deviation for both the exact and rounded amounts are displayed. The percent difference between the sums of the exact and rounded amounts is calculated and a determination is made as to whether or not it's cost effective to round the dollar values.

The following functions have been written:

The getAmount funtion takes no arguments and returns a "valid" amount. Its purpose is to "get" an exact dollar amount from the user and verify that it is either 0 or positive. If the value entered is valid, it is returned to the calling function. If the value entered is invalid, an error message is displayed and the user is prompted for a new value. This is done until a valid value is entered.

The roundAmount function takes one double argument: a dollar amount to be rounded to the nearest $10 value and returns a double: the rounded dollar amount. It rounds the exact dollar amount by:

The calcAverage function takes two arguments: a double value that represents a sum of dollar amounts, and an integer value that represents a count of dollar amounts. Its purpose is to calculate and return an average if the count is greater than 0. If the count is less than or equal to 0, -1 is returned.

The calcStdDev function takes three arguments: a double value that represents a sum of dollar amounts, a double value that represents the sum of the squared dollar amounts, and an integer value that represents a count of dollar amounts. The purpose of this function is to calculate and return the standard deviation if the count is greater than 1. If the count is less than 1, -1 is returned. The formula for standard deviation is:

where n is the number of entries (count).

The calcDiff function takes two arguments: a double value that represents a sum of the exact dollar amounts, and a double value that represents the sum of the rounded dollar amounts. The purpose of this function is to calculate and return the percent difference between the sum of the exact values and the sum of the rounded values. The percent difference formula is:

Thefabs()function is used to find the absolute value.

DO NOT WRITE ANY FUNCTIONS. Simply go through the program that has been provided and put in function calls where indicated. For example:

This box should be followed by a call to the getAmount function that is described above. There are 8 boxes similar to this in the program, which means 8 function calls need to be be added.

The float/double results will be displayed with exactly 2 digits after the decimal point, including zeros.

Explanation / Answer

Here is the code with the blanks filled in: http://pastebin.com/es05MWXX

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote