57 lines
1.8 KiB
Text
57 lines
1.8 KiB
Text
#define N 3 'show the top three employees of each rank
|
|
|
|
'here is all the data to be read in
|
|
|
|
data "Tyler Bennett","E10297",32000,"D101"
|
|
data "John Rappl","E21437",47000,"D050"
|
|
data "George Woltman","E00127",53500,"D101"
|
|
data "Adam Smith","E63535",18000,"D202"
|
|
data "Claire Buckman","E39876",27800,"D202"
|
|
data "David McClellan","E04242",41500,"D101"
|
|
data "Rich Holcomb","E01234",49500,"D202"
|
|
data "Nathan Adams","E41298",21900,"D050"
|
|
data "Richard Potter","E43128",15900,"D101"
|
|
data "David Motsinger","E27002",19250,"D202"
|
|
data "Tim Sampair","E03033",27000,"D101"
|
|
data "Kim Arlich","E10001",57000,"D190"
|
|
data "Timothy Grove","E16398",29900,"D190"
|
|
|
|
type employee
|
|
'define a data type for employees
|
|
nm as string*32 'name
|
|
en as string*6 'employee number
|
|
sl as uinteger 'salary
|
|
dp as string*4 'department
|
|
fl as boolean 'a flag
|
|
end type
|
|
|
|
dim as employee emp(1 to 13)
|
|
dim as uinteger e, d, x, ce, cs
|
|
dim as string*4 dept(1 to 4) = {"D050", "D101", "D190", "D202"}
|
|
|
|
for e = 1 to 13
|
|
'put all the employee data into an array
|
|
read emp(e).nm
|
|
read emp(e).en
|
|
read emp(e).sl
|
|
read emp(e).dp
|
|
emp(e).fl = false
|
|
next e
|
|
|
|
for d = 1 to 4 'look at each department
|
|
print "Department ";dept(d);":"
|
|
for x = 1 to N 'top N employees
|
|
cs = 0
|
|
ce = 0
|
|
for e = 1 to 13 'look through employees
|
|
if emp(e).dp = dept(d) andalso emp(e).fl = false andalso emp(e).sl > cs then
|
|
emp(ce).fl = false 'unflag the previous champion so they can be found on the next pass
|
|
ce = e
|
|
cs = emp(e).sl
|
|
emp(e).fl = true 'flag this employee so that on the next pass we can get the next richest
|
|
endif
|
|
next e
|
|
if ce>0 then print emp(ce).nm;" ";emp(ce).en;" ";emp(ce).sl;" ";emp(ce).dp
|
|
next x
|
|
print
|
|
next d
|