Function whose job is to input

Assignment Help Basic Computer Science
Reference no: EM13161019

Write a function whose job is to input #'s, non-# to quit, recover from the input failure by calling recover(), and tell main some statistics about the numbers read.

A. unsigned readA();

Read unsigned #'s, non-# to quit, recover, return the sum of all #'s read.

For example, if main says

            cout <<"The total is " <<readA() <<endl;

and if the user types

            2 4 6 8 blah

then readA will read the numbers 2, 4, 6, 8, keeping track of the total of the numbers read, readA will then choke on the "blah", readA will then, call recover() so that cin recovers from the input failure and moves past the "blah", readA will then return the 20, then main will resume the cout statement so that it outputs

            The total is 20

B. void readB( double & sum );

Same as above, except that readB informs main of the answer by setting a reference arg instead of by giving a return value.

main should call readB and main should output the answer.

C. double readC();

This time readC returns the largest #. readC should c&d if there aren't any #'s before the input failure.

D. void readD( double & max );

readD, like above, informs main of the largest #, again complaining and dying if there aren't any numbers, but this time readD informs main of the answer through a reference arg instead of a return value.

E. void readE( double & max, double & min, double & average );

Like above, but this time there are 3 values that the function informs the main function of instead of just 1. (As readE moves through the input data, you'll need to keep track of 4 quantities as you go:

            the largest # seen so far

            the smallest # seen so far

            the number of #'s seen so far

            the sum of the #'s seen so far

)

Reference no: EM13161019

Questions Cloud

Hexadeciaml numerals are integers written : Hexadeciaml numerals are integers written in base 16. The digits used are '0' through '9' plus 'a' for the "digit 10", 'b' for the "digit 11", 'c' for the "digit 12", 'd' for the "digit 13", 'e' for the "digit 14", and 'f' for the "digit 15". For exa..
Program that will ask for a month : Write a program that will ask for a month (1-12) and a year (yyyy). the program should then produce a calendar showing the month name and year and have all of the days displayed under it.
Function whose job is to output some sequence : Write a function whose job is to output some sequence of "interesting" #'s. The numbers should be separated from one another somehow so they don't all run together. This function may need to call another function, where the second function determines..
What is the probability : Suppose that the probability than an incoming email is a spam is p(S), that the probability that the word "w" occurs in the subject line of the spam is p(w), and that q(w) is the probability that the word "w" occurs in the subject line of an email th..
Function whose job is to input : Write a function whose job is to input #'s, non-# to quit, recover from the input failure by calling recover(), and tell main some statistics about the numbers read. A. unsigned readA();
The user enter the total rainfall for each of 12 months : Write a program that lets the user enter the total rainfall for each of 12 months (starting with January) into an array of doubles. The program should calculate and display:the total rainfall for the year,the average monthly rainfall,and the months w..
When the user presses a button : When the user presses a button, get the text from text field. Now extract the words from the text one at a time and find the largest word of length 4 or more. Let's call this largest word X for now. In response, create a question based on the length ..
Write a program that takes a positive integer : Write a program that takes a positive integer from the user and prints the rightmost digit of that integer. This is a sample output: Enter an integer: 1247
Desktop publishing system : Consider a desktop publishing system used to produce documents for various organizations. a. Give an example of a type of publication for which confidentiality of the stored data is the most important requirement

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Ways which online tutoring varies from in-person tutoring

In three paragraphs or more, explain the following: Write down three ways in which online tutoring varies from in-person tutoring.

  What sort of system are you building

Create a spreadsheet listing all of the components, their prices, the place or website you could purchase, the cost of each component, and an explanation of why you would choose this part - What sort of system are you building? What tasks are requi..

  Shortest path between each pair of nodes using floyd''s meth

find the shortest path between each pair of nodes using floyd's method

  Calculate performance of cache and the average cpi

Assume the instruction cache miss rate is 0.5% and the data cache miss rate is 1%. Calculate the performance of the cache (CPU execution time) and the average CPI.

  Each cycle in an instruction cycle

Suppose each cycle in an instruction cycle takes an average of 5 clock cycles. Determine the number of clock cycles needed to process 10 instructions without and with a pipeline

  Impact of meals on world-ecological and economic perspective

Write about the impact that two (2) of your meals have on our world from an ecological and economic perspective.

  Explain how data and information can be categorised

What is meant by data? What is meant by information? How can data information be categorised? Where from? Used for?

  Create flowchart and psuedo code for math program

Create flowchart and psuedo code for math program which permits the user to enter two separate numbers and choose one of four mathematical operations (add, subtract, mutiply, divide).

  Write a program that reads the data in the file and displays

Write a program that reads the data in the file and displays the car number, miles driven, gallons used and the miles per gallon for each car.

  Determine relation of m and n-existence of a hash function

Determine the most general relation of m and n that guarantees the existence of a hash function in H that causes no collision when hashing [n] into [m].

  Explain potential challenge of collaboration of firms

Author suggests ways to do this. Explain the potential challenge that this kind of collaboration might face and explain the way of dealing with it.

  Error detection-correction facility-interpreters- compilers

Compare error detection and correction facilities of interpreters and compilers. Compare static and dynamic linking. With respect to the requirements of modern applications, what are the shortcomings of 3GLs?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd