|
|
#1 |
|
Beta Member
Join Date: Jun 2011
Posts: 2
|
I am trying to write an array process for employee names and their salaries, and I also have to determine the mean salary and as well as the number of salaries above and below the mean. Can someone tell me if I am this simple array process I have written is correct
Here is my psuedocode This program will allow a user to input an employee name and salary The output will contain the mean salary as well as the number of salaries above and below the mean As well as the number of salaries above and below the mean //Arrays used: // Name (K) = Array for employees names //Salary (K) = Array of salaries // //Variables used: //Mean = Mean of all employees Salaries //Upmean = Number of employees making more than the mean //Downmean = Number of employees making less than the mean //Sum = Sum of all salaries //Countm = Counter of mean //Countup = Counter for all numbers of salaries above mean //Countdown = Counter for all numbers of salaries below the mean Main: Call welcome message Call input data Call Calculate Call output data End Write, “Welcome message” Write, “beginning of salary program” End Input data Declare name (100) of strings Declare Salary (100) of real Declare mean, upmean, downmean as real Set sum = 0 Set Countm = 0 Set Countup = 0 Set Countdown= 0 Write, “Enter employee name and salary” Write, “Enter 0 when done” Input Name (K), Salary (K) While Name < > 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 Input Data Calculate //Here is mean found Set mean = Sum / Countm // Here number of employees making more than the mean is found For K Step to CountM If Salary (K) > “Mean Then “ Set Countup = Countup + 1 End Calculations Output Data 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,” Countdown, “employees who make less than the (average)” End output data |
|
|
|
|
|
#2 |
|
In Runtime
Join Date: Mar 2011
Posts: 274
|
It looks pretty good, for the case that an employee makes exactly the average, they will be counted in the "make less" category. Is that your intent? If not, you should test for Salary >= Mean.
BTW, you could do this very easily with a spreadsheet. The advantage is that as salaries change, you would be able to update those salary changes without needing to re-enter all of the data. Of course if this is for a class or something disregard about the spreadsheet. |
|
|
|
|
|
#3 |
|
Beta Member
Join Date: Jun 2011
Posts: 2
|
Interesting to find out I could use spreadsheet. I would be saving time further down the road "Thanks for the feedback"
|
|
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|