Houser_MatthewFix1_M04
docx
keyboard_arrow_up
School
ITT Tech *
*We aren’t endorsed by this school
Course
1110
Subject
Communications
Date
Feb 20, 2024
Type
docx
Pages
9
Uploaded by housermatt87
Matthew Houser
SDEV 120
Debugging M04
Debug 1
// This pseudocode should create a report that contains an
// apartment complex rental agent's commission. 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 commissionEarned
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
if 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
/// declared num commissionEarned
///Changed output salesperson_ID to input salesPersonID
///changed if numBedrooms > 1 then
/// commission = COMM_1
///to commissionEarned = COMM_1
///changed commission = COMM_4 to ///corrected salesPersonName in the outout
/// added if to commissionEarned = COMM_STUDIO
Debug 2
// This pseudocode should create a list that describes annual profit
// statistics for a retail store. Input records contain a department
// name (for example, “Cosmetics”) and profits for each quarter for
// the last two years. The program should determine whether
// the profit is higher, lower, or the same
// for this full year compared to the last full year.
start
Declarations
string department
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
num salesQuarter1ThisYear
num salesQuarter2ThisYear
num salesQuarter3ThisYear
num salesQuarter4ThisYear
num salesQuarter1LastYear num salesQuarter2LastYear
num salesQuarter3LastYear
num salesQuarter4LastYear num totalThisYear
num totalLastYear
string status
num QUIT = "ZZZZ"
housekeeping()
while department <> QUIT
compareProfit()
endwhile
finishUp()
stop
housekeeping()
output "Enter department name or ", QUIT, " to quit "
input department
return
compareProfit()
getSalesData()
sumSalesData()
if totalThisYear > totalLastYear then
status = "Higher"
else
if totalThisYear < totalLastYear then
status = "Lower"
else totalThisYear = totalLastYear then
status = "Same"
endif
endif
output department, status
output "Enter department name or ", QUIT, " to quit "
input department
return
getSalesData()
output "Enter sales for first quarter this year "
input salesQuarter1ThisYear
output "Enter sales for second quarter this year "
input salesQuarter2ThisYear
output "Enter sales for third quarter this year "
input salesQuarter3ThisYear
output "Enter sales for fourth quarter this year "
input salesQuarter4ThisYear
output "Enter sales for first quarter last year "
input salesQuarter1LastYear
output "Enter sales for second quarter last year "
input salesQuarter2LastYear
output "Enter sales for third quarter last year "
input salesQuarter3LastYear
output "Enter sales for fourth quarter last year "
input salesQuarter4LastYear
return
sumSalesData()
totalThisYear = salesQuarter1ThisYear + salesQuarter2ThisYear +
salesQuarter3ThisYear + salesQuarter4ThisYear
totalLastYear = salesQuarter1LastYear + salesQuarter2LastYear +
salesQuarter3LastYear + salesQuarter4LastYear
return
finishUp()
output "End of report"
return
/// correcter the second num salesQuarter3ThisYear to num salesQuarter4ThisYear
///chnaged input dept to input department
///changed if totalThisYear = totalLastYear then to if totalThisYear > totalLastYear then
///changed if totalThisYear <= totalLastYear then to if totalThisYear < totalLastYear then
///n added else totalThisYear = totalLastYear then
/// status = "Same"
/// changed input salesQuarter1ThisYear to input salesQuarter2ThisYear
/// changed input salesQuarter1ThisYear to input salesQuarter3ThisYear
///changed input salesQuarter3LastYear to input salesQuarter2LastYear
///changed input salesQuarter3LastYear to input salesQuarter4LastYear
/// changed salesQuarter2ThisYear + salesQuarter4ThisYea to salesQuarter3ThisYear + salesQuarter4ThisYear
///changed = salesQuarter2LastYear to = salesQuarter1LastYear
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Debug 3
// This pseudocode should determine and output
// the rental fees for cars.
// Standard cars rent for $65 per day,
// compacts rent for $40 per day,
// and subcompacts rent for $30 per day.
// Rentals for at least 7 days receive a 20% discount.
// An error message is displayed if the car type
// is not valid.
start
Declarations
string carType
num days
num rate
num STD_RATE = 65
num COM_RATE = 40
num SUB_RATE = 30
num DAYS_FOR_DISCOUNT = 7
num DISCOUNT_RATE = 0.20
string QUIT = "ZZZZ"
getReady()
while carType <> QUIT
detailLoop()
endwhile
finish()
stop
getReady()
output Enter car type or , QUIT, to quit
input carType
return
detailLoop()
output "Enter days rented "
input days
if carType = "Standard" then
rate = STD_RATE
else
if carType = "Compact" then
rate = COM_RATE
else
if carType = "Subcompact" then
rate = SUB_RATE
else
rate = 0
output "Invalid car type"
endif
endif
endif
if rate <> 0
if days >= DAYS_FOR_DISCOUNT then
rate = rate * DISCOUNT_RATE
endif
output carType, days
output "Enter car type or ", QUIT, " to quit "
input carType
return
finish()
output "End of program"
return
///added rate decliration to list
/// changed DAYS_FOR_DISCOUNT = 7
/// line 39 changed car_Type to carType
///line 39 changed COMPACT_RATE to COMP_RATE
Debug 4 /// num discount2 = 0.02 changed to num discount2=0.20
///change item < CUT_OFF1? TO item = CUT_OFF1 OR item <CUT_OFF2
///change item < CUT_OFF1 TO item >= CUT_OFF2
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help