...

# need help with this prog..

bob0809
10-19-2004, 07:05 PM
Write a program that reads in any 25 decimal numbers from standart input
source (terminal), determins the actual and absolute lowest & largest
values, and computes average of all the given numbers. You may use
any/all programming techniques we have learned in class, and only those
(no arrays, no recursion, no ADTs).

Sample run:
---------------------------------------------------------
Please input 25 decimal numbers for processing:

5 d 6 7.4 8.23 0.216 -45.7 3 56 124 532 5.237 67.3 45.2 56.9
34.3 361.238 02 -34.2 348.2 32.45 0.33 1.56 7.45 -3.276

Processing...

Actual Min: - 045.70
Actual Max: + 361.24

Absolute Min: + 000.22
Absolute Max: + 361.24

Absolute Total: 1887.187
Average: 75.487

----------------------------------------------------------

Note:
if sample output inside the message is not formated, look for formated
example in attached file - sample_output.txt

All output must be strictly formated:
- decimal points are aligned
- all min/max numbers are printed with precision of 2 decimal places
- total & average are printer with precision of 3 decimal places
- all min/max values have their signs printed, also with strict
formating (one column)
- always use absolute value to compute average

Tips:
1. Do not write your own functions to handle input of all the special
cases, e.x. negative numbers, decimal, etc.
C++ library for cout/cin functions perform all that processing for you

2. you will have to write your own routeen to compute average
3. for that you will have to keep track of all the required
information, ex.
- real min/max
- absolute min/max
- absolute sum

4. you don't need to keep count how many numbers you totaled for
average computation - it is given to you in the problem statment - 25.
5. You must use some sort of a loop to read in all 25 numbers and
perform processing on each input as it comes in.
6. Do NOT write your own function to determine absolute value - use one
already provided to you in math library.

bob0809
10-19-2004, 07:34 PM
ohk i wrote this in my prog

#include <iostream>
#include <cmath>
using namespace std;
void main()
{
//how can i declare 25 numbers?? thts y i m confuse i cant use array for this prog//

if someone can tell me how can i declare 25 numbers then i might able to do it

Roy Sinclair
10-19-2004, 10:41 PM
Your assignment says to READ the numbers from STDIN. None of the statistics you're computing require you to have all 25 numbers at once so you can simply take each number as it's entered and run all your checks against it then return for the next number until you've read all 25.