Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Each file starts with some comments that describe the problem. Comments are line

ID: 3701715 • Letter: E

Question

Each file starts with some comments that describe the problem. Comments are lines that begin with two slashes (//). Following the comments, each file contains pseudocode that has one or more bugs you must find and correct.

// This pseudocode should create a report that contains a
// rental agent's commission at an apartment complex. The
// program accepts the ID number and name of the agent who
// rented the apartment, and the number of bedrooms in the
// apartment. The commission is $100 for renting a three-bedroom
// apartment, $75 for renting a two-bedroom apartment, $55 for
// renting a one-bedroom apartment, and $30 for renting a studio
// (zero-bedroom) apartment. Output is the salesperson’s
// name and ID number and the commission earned on the rental.
start
   Declarations
      num salesPersonID
      string salesPersonName
      num numBedrooms
      num COMM_3 = $100.00
      num COMM_2 = $75.00
      num COMM_1 = $55.00
      num COMM_STUDIO = $30.00
      num QUIT = 9999
   getReady()
   while salesPersonID <> QUIT
      detailLoop()
   endwhile
   finish()
stop

getReady()
   output "Enter salesperson ID or ", QUIT, " to quit "
   output salesperson_ID
return

detailLoop()
   output "Enter name "
   input salesPersonName
   output "Enter number of bedrooms rented "
   input numBedrooms
   if numBedrooms > 3 then
      commissionEarned = COMM_3
   else
      if numBedrooms < 2 then
         commissionEarned = COMM_2
      else
         if numBedrooms > 1 then
            commission = COMM_1
         else
            commission = COMM_4
         endif
      endif
   endif
   output salesPersonID, salesPersName, commissionEarned
   output "Enter salesperson ID or ", QUIT, " to quit "
   input salesPersonID
return

finish()
   output "End of report"
return

Explanation / Answer


In getReady() method there is output statement.

output salesperson_ID

It should be input statement to read the value salesPersonID

input salesPersonID

commissionEarned variable is not declared and used in the program. You need to declare the variable commissionEarned.

num commissionEarned


The problem specification only mentions about three-bedroom to zero-bedroom.
So lets assume the first condition to be >= 3.

All the conditions are not correct. Please see the corrected code below.

In conditions commission is a Typo. It should be commissionEarned.
COMM_4 is not defined it should be COMM_STUDIO.

         if numBedrooms == 1 then
            commissionEarned = COMM_1
         else
            commission = COMM_STUDIO
         endif
  

In the output statement salesPersName is a typo.

output salesPersonID, salesPersName, commissionEarned

Corrected Pseudocode:
-------------------------------

start
   Declarations
      num salesPersonID
      string salesPersonName
      num numBedrooms
      num commissionEarned
      num COMM_3 = $100.00
      num COMM_2 = $75.00
      num COMM_1 = $55.00
      num COMM_STUDIO = $30.00
      num QUIT = 9999
   getReady()
   while salesPersonID <> QUIT
      detailLoop()
   endwhile
   finish()
stop

getReady()
   output "Enter salesperson ID or ", QUIT, " to quit "
   input salesPersonID
return

detailLoop()
   output "Enter name "
   input salesPersonName
   output "Enter number of bedrooms rented "
   input numBedrooms
   if numBedrooms >= 3 then
      commissionEarned = COMM_3
   else
      if numBedrooms == 2 then
         commissionEarned = COMM_2
      else
         if numBedrooms == 1 then
            commissionEarned = COMM_1
         else
            commissionEarned = COMM_STUDIO
         endif
      endif
   endif
   output salesPersonID, salesPersonName, commissionEarned
   output "Enter salesperson ID or ", QUIT, " to quit "
   input salesPersonID
return

finish()
   output "End of report"
return


Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote