I already turned it on so you do not help me cheat. Just wondering if this looks right:
Purpose: Enter a list of employee names and salaries and determine the average (average) salary, as well as the number of salaries above and below the average.
Plan: Allow entry of names and salaries Calculate average value Sort values Number of values above Average value Number of values below Average value
Main
Call WelcomeMessage
Call InputData
Call Calculate
Call OutputData
End Program
WelcomeMessage
Write, "Beginning the Salary Program"
End WelcomeMessage
InputData
Declare Name(100) Of Strings
Declare Salary(100) Of Real
Declare Mean, UpMean, DwnMean As Real
Set Sum = 0
Set CountM = 0
Set CountUp = 0
Set CountDwn = 0
Write, "Enter Employee name and Salary."
Write, "Enter *,0 when done."
Input Name(K), Salary(K)
While Name(K) <> "*"
Set CountM = CountM + 1
Set Sum = Sum + Salary
Write, "Enter Employee name and Salary."
Write, "Enter *,0 when done."
Input Name(K), Salary(K)
End While
End InputData
Calculation
Set Mean = Sum / CountM
For K = Step 1 to CountM
If Salary(K) > Mean Then
Set CountUp = CountUp + 1
End If
Set CountDwn = CountM - CountUp
If Salary(K) = Mean Then
Set CountDwn = CountDwn - 1
End If
End Calculation
OutputData
Write, "There were," CountM, "salaries entered."
Write, "The mean salary is:", Mean
Write, "There are", CountUp, "employees who make more than the average"
Write, "There are", CountDwn, "employees who make less than the average"
End OutputData
source
share