Stats for floating point values

Write a program when completed will compute three statistics
for a set of floating-point values. These statistics include:
a) the count of all numbers,
b) the number of items below a lower threshold, and
c) the number of items above an upper threshold.



A sample run is as follows, where 20 was input as the lower
threshold, 40 was input as the upper threshold, and the
numbers: 19 30 0 33 45.8 30.5 48.8 60.3 20 were entered
to process.

Enter lower threshold: 20
Enter upper threshold: 40
19 30 0 33 45.8 30.5 48.8 60.3 20

Total count of numbers: 9
Below 20.000: 2
Above 40.000: 3


so i am writing a program for my job and i seem to be at a stand still with this portion of it. I have defined how i want to do it i just can't get the coding correct
any help would be great
So you'll need a couple of if()'s in your program, and an understanding of loops and arrays.
Question; is the user inputting a set maximum of numbers, or could they simply continue typing in number after number? also does the user input the thresholds?

here's my idea of how it would run (Not a working program);

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
cout<<"Enter lower threshold: "<< x
cout<<Enter upper threshold: "<<y //(use cin for the x and y thresholds if that applies)
while(some letter isn't pressed)
    {
    cout<<Ask the user for number inputs;
    cin>>numbers[count]
    count++
    if(letter is pressed)
        {
        end this loop
        }
}

count2=0
while(count2<count)
{
    if(number[count2] is above x)
     {
     upperthreshold++ 
     }
     else if(number[count2] is below y)
     {
      lowthreshold++
     }
count2++
}
cout<<"Total count of all numbers; "<<count<<endl
cout<<"Numbers under low threshold; "<<lowthreshold<<endl
cout<<"Numbers above upper threshold; "<<upperthreshold<<endl
 


This obviously is not a working example, but it has the very basics of the idea.
Last edited on
Topic archived. No new replies allowed.