Randy's Recreational Vehicles pays its salespeople once every three months. Salespeople receive one-quarter of their annual base salary plus 7 percent of all sales made in the last three-month period. Randy creates an input file with four records for each salesperson. The first of the four records contains the salesperson's name and annual base salary, while each of the three records that follow contains the name of a month and the monthly sales figure. For example, the first eight records in the file might contain the following data:
Kimball 20000
April 30000
May 40000
June 60000
Johnson 15000
April 65000
May 78000
June 135500
Because the two types of records contain data in the same format - a character field followed by a numeric field - you can define one input record format containing two variables that you use with either type of record. Design the logic for the program that reads a salesperson's record, and if not at eof (end of file), reads the next three records in a loop, accumulating sales and computing commissions. For each salesperson, print the quarterly base salary, the three commission amounts, and the total salary, which is the quarterly base plus the three commission amounts.
------------------------------------------------------------------------------------------------------------------------------
Pseudocode:
start
perform housekeeping()
do
perform displaySalary()
while not eof
endwhile
perform finish()
end
housekeeping()
declare variables
inRecord
inNameOrMonth
inSalaryOrSalesFigure
perform printHeadings()
monthCommission
totalSalary
counter
print mainHeading, columnHeading
open files
EMPLOYEESALARY, printer
read inRecord
return
printHeadings()
mainHeading = Employees Quarterly Salary
columnHeading = Name Base Salary April May June Total
return
displaySalary()
print nameOrMonth
totalSalary = inSalaryOrSalesFigure * 0.25
print totalSalary
if inRecord == eof
return
endif
counter = 0
while counter < 2
read inRecord
monthCommission = inSalaryOrSalesFigure * 0.07
print monthCommission
totalSalary = totalSalary + monthCommission
counter = counter + 1
endwhile
print totalSalary
read inRecord
return
finish()
close files
EMPLOYEESALARY, printer
return