- #1
Travian
- 64
- 0
Homework Statement
I have to write this algorithm in pseudocode that finds and displays the largest of a list of positive numbers entered by the user and the sum of the positive numbers. The user should indicate that he has finished entering numbers by entering a zero.
For example the user might enter
3 4 -9 8 -2 0
the algorithm should report that the largest of the positive numbers is 8 and that the sum of positive numbers is 15.
Homework Equations
The Attempt at a Solution
Im on it right now and that's what i have done so far:
Declare Sum as float
Declare Counter as integer
Declare Number as float
Declare Average as float
Declare highestNumber as integer
highestNumber = score(0)
FOR index 1 to 6
IF number(index) > highestNumber THEN
highestNumber=number(index)
ENDIF
ENDFOR
Set Sum = 0
Set Count = 0
Display "Enter a number. Enter 0 when done"
Get Number
WHILE Number > 0 THEN
Set Count = Count 1
Set Sum = Sum Number
ENDWHILE
IF Count != 0
Set Average = Sum/Counter
ENDIF
Can someone help me to finish it, because I am really stuck here:/