In: Computer Science
Diana Lee, a
supervisor in a manufacturing company, wants to know which
employees have increased their production this year over last year
so that she can issue them certificates of commendation and
bonuses. Design a flowchart or pseudocode for the
following:
a. A program that
continuously accepts each worker’s first and last names, this
year’s number of units produced, and last year’s number of units
produced. Display each employee’s data with a message indicating
whether the employee’s production has increased over last year’s
production.
b. A program
that accepts each worker’s data and displays the employee name and
a bonus amount. The bonuses will be distributed as
follows:
If this year’s production
is greater than last year’s production and this year’s production
is:
1000 units or
fewer, the bonus is $25
1001 to
3000 units, the bonus is $50
3001 to
6000 units, the bonus is $100
6001
units and up, the bonus is $200
c. Modify Exercise 9b to reflect the following new facts, and have the program execute as efficiently as possible:
Thirty percent of
employees have greater production this year than last
year.
Sixty
percent of employees produce over 6000 units per year; 20 percent
produce 3001 to 6000 units; 15 percent produce 1001 to 3000 units;
and only 5 percent produce fewer than 1001 unit
a.
Start
Declare fname as string, lname as string
Declare yearunits as integer, lastyearunits as integer
Declare terminate as string
Let terminate=""
While terminate != "n" do
Print "Enter first name"
Read fname
Print "Enter last name"
Read lName
Print "Enter this year units produced"
Read yearunits
Print "Enter last year units produced"
Read lastyearunits
if yearsunits>lastyearunits Then
Print "Employee's production has increased over last year"
Else yearsunits<lastyearunits Then
Print "Employee's production has decreased over last year"
Else
Print "Employee's production is same as last year"
End If
Print "Want to continue ? Press y to continue or n to exit"
Read terminate
End While
Stop
b.
Start
Declare fname as string, lname as string, bonus as string
Declare yearunits as integer, lastyearunits as integer
Declare terminate as string
Let terminate=""
While terminate != "n" do
Print "Enter first name"
Read fname
Print "Enter the last name"
Read lname
Print "Enter this year units produced"
Read yearsunits
Print "Enter last year units produced"
Read lastyearunits
Let bonus=0
if yearunits>lastyearunits Then
if yearunits<=1000 Then
set bonus="$25"
else if yearunits>1000 and yearunits<=3000 Then
set bonus="$50"
else if yearunits>3000 and yearunits<=6000 Then
set bonus="$100"
else if yearunits>6000 Then
set bonus="$200"
End IF
Print "The employee " + fname + " " +lname + " has got bonus of "+
bonus
Else
Print "The employee " + fname + " " +lname + " has not got bonus
"
End If
Print "Want to continue ? Press y to continue or n to
exit"
Read terminateProgram
End While
Stop
c.
Start
Declare fname as string, lname as string, bonus as string
Declare yearunits as integer, lastyearunits as integer
Declare terminate as string
Let terminate=""
Declare pgproductionas double
Declare avg6unit as double, avg3to6 as double, avgless1001 as
double, avgmorethanlast as double
Declare int6unit as integer, int3to6 as integer, intless1001 as
integer
Let int6unit=0
Let int3to6=0
Let intless1001=0
Declare avgtwoYrProd as double
Declare intmorethanlast as integer, totalemp as integer
Let intmorethanlast =0
Let totalemp =0
While terminateProgram != "n" do
Print "Enter the first name"
Read fname
Print "Enter the last name"
Read lname
Print "Enter this year units produced"
Read yearunits
Print "Enter last year units produced"
Read lastyearunits
Let bonus=0
Set avgtwoYrProd=(yearunits+lastyearunits)/2
if avgtwoYrProd<=1000 Then
Set intless1001=intless1001 + 1
else if avgtwoYrProd>3000 and avgtwoYrProd<=6000 Then
Set int3to6=int3to6 + 1
else if avgtwoYrProd>6000 Then
Set int6unit=int6unit + 1
End IF
if yearunits>lastyearunits Then
Print "Employee's production has increased over last year"
set intmorethanlast = intmorethanlast +1
if yearunits<=1000 Then
set bonus="$25"
else if yearunits>1000 and yearunits<=3000 Then
set bonus="$50"
else if yearunits>3000 and yearunits<=6000 Then
set bonus="$100"
else if yearunits>6000 Then
set bonus="$200"
End IF
Print "The employee " + fname + " " +lname + " has got bonus of "+
bonus
Else
Print "The employee " + fname + " " +lname + " has not got any
bonus "
End If
Set totalemp= totalemp+1
Print "Want to continue ? Press y to continue or n to
exit"
Read terminate
End While
set avgmorethanlast=(intmorethanlast/totalemp) * 100
Print avgmorethanlast +" percent of the employees have greater
production this year than last year. "
Set avg6unit=(int6unit/totalemp) * 100
Print avg6unit +" percent of employees produce over 6000 units per
year "
Set avg3to6=(int3to6/totalemp) * 100
Print avg3to6 +" percent produce 3001 to 6000 "
Set avgless1001=(intless1001/totalemp) * 100
Print avgless1001 +" percent produce fewer than 1001 "
Stop