Modify the program from exercise 8 to use double instead of int. Also, make a vector of
Question:
Modify the program from exercise 8 to use double instead of int. Also, make a vector of doubles containing the N–1 differences between adjacent values and write out that vector of differences.
Data from Exercise 8
Write a program that reads and stores a series of integers and then computes the sum of the first N integers. First ask for N, then read the values into a vector, then calculate the sum of the first N values. For example: “Please enter the number of values you want to sum:”
3
“Please enter some integers (press '|' to stop):”
12 23 13 24 15 |
“The sum of the fi rst 3 numbers ( 12 23 13 ) is 48.”
Handle all inputs. For example, make sure to give an error message if the user asks for a sum of more numbers than there are in the vector.
Step by Step Answer:
Students also viewed these Computer science questions
-
Modify the program from exercise 8 to write out an error if the result cannot be represented as an int. Data from Exercise 8 Write a program that reads and stores a series of integers and then...
-
Write a program that reads and stores a series of integers and then computes the sum of the first N integers. First ask for N, then read the values into a vector, then calculate the sum of the first...
-
Bilbo?s Hospital needs a program to print out patient bills. There are 2 categories of patients, in-patient and out-patient. The category will be indicated with and 'I' or 'O'. In addition to the...
-
Let a = (123) (45) = S, and b = (23) (14) = S5, then aba is equal to (13) (25) (135) (24) (15) (23) (123) (45)
-
The speed at which men versus women mentally rotated an object. Fifteen men and 15 women mentally rotated the object. The men mentally rotated it in 0.0313 s less time than the women. The value of...
-
Data analytics is the process of examining data sets in order to draw conclusions about the information they contain. If you havent completed any of the prior data analytics cases, follow the...
-
True or false: Peak-to-peak readings are used for displacement only.
-
From the following transactions as well as additional data, please complete the entire accounting cycle for Parkers Plowing (use the chart of accounts for 5A-3). 201X Jan. 1 Parker invested $10,000...
-
Evil One drops Joe out a plane flying horizontally. After 2 seconds of thought, he throws a rock vertically down to scare Joe (even more). If the rock is moving 10 m/s faster than Joe when it passes...
-
In Problem S1-12, if Wiley is able to assign probabilities of occurrence of 0.23 to unfavorable market conditions, 0.46 for the same market conditions, and 0.31 for favorable market conditions, what...
-
List four potential sources of program errors discussed in the text.
-
How do you know if a result is plausible? What techniques do you have to answer such questions?
-
On March 31, 2014, Taggert Company had a cash balance per books of $5,174.20. The statement from Western Bank on that date showed a balance of $6,041.40. A comparison of the bank statement with the...
-
Paradise Realty Co. pays weekly salaries of $25,500 on Friday for a five-day workweek ending on that day. Journalize the necessary adjusting entry at the end of the accounting period, assuming that...
-
The adjusting entry for accrued wages was omitted at July 31, the end of the current year. Indicate which items will be in error, because of the omission, on (a) the income statement for the current...
-
The balance in the unearned fees account, before adjustment at the end of the year, is $18,000. Journalize the adjusting entry required if the amount of unearned fees at the end of the year is $3,600.
-
On February 11, 20Y9, Quick Fix Company purchased $2,250 of supplies on account. In Quick Fixs chart of accounts, the supplies account is No. 15, and the accounts payable account is No. 21. a....
-
Identify each of the following accounts of Liken Services Co. as asset, liability, stockholders equity, revenue, or expense, and state in each case whether the normal balance is a debit or a credit:...
-
Chelsea, who is single, purchases land for investment purposes in 2011 at a cost of $22,000. In 2016, she sells the land for $38,000. Chelsea's taxable income without considering the land sale is...
-
Figure displays a 12.0 V battery 3 four uncharged capacitors of capacitances C1 = 4.00F, C2 = 6.00F, and C3 = 3.00F. The switch is thrown to the left side until capacitor 1 is fully charged. Then the...
-
If the approach described in the previous problem were implemented as part of the TreeMap class, what additionalmodifications (if any) would be necessary to a subclass such as AVLTreeMap in order to...
-
Suppose we wish to support a new method countRange(k 1 , k 2 ) that determines how many keys of a sorted map fall in the specified range. We could clearly implement this in O(s + h) time by adapting...
-
For a key k that is not found in binary search tree T, prove that both the greatest key less than k and the least key greater than k lie on the path traced by the search for k.
-
The hawkins company maintains one set of financial records for financial reporting purpose. separate records are also kept for tax compliance purpose. why is that necessary?
-
Managerial accounting must follow GAAP. Financial accounting does not. There is no significant difference between financial and managerial accounting. Managerial accounting provides information for...
-
Troy Abraham had the following assets and liabilities as of October 1, 2019. Assets Liabilities Cash $6,500 Automobile $8,700House $165,000 Contents of Home $6,400 Prepaid Insurance $1,700 Unpaid...
Study smarter with the SolutionInn App