FIX1_M04
docx
keyboard_arrow_up
School
Ivy Tech Community College, Northcentral *
*We aren’t endorsed by this school
Course
140
Subject
Communications
Date
Apr 3, 2024
Type
docx
Pages
7
Uploaded by PresidentWillpowerJaguar37
BUNYAMIN FUAT YILDIZ DEBUG 04-01
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
num commissionEarned // Added declaration for commissionEarned
getReady() while salesPersonID <> QUIT detailLoop() getReady() // Moved getReady() for continuous input
endwhile
finish() stop
getReady()
output "Enter salesperson ID or ", QUIT, " to quit: "
input salesPersonID // Fixed: input statement now takes salesperson ID
if salesPersonID <> QUIT then
output "Enter name: "
input salesPersonName
endif return
detailLoop()
output "Enter number of bedrooms rented: "
input numBedrooms
if numBedrooms == 3 then commissionEarned = COMM_3
elseif numBedrooms == 2 then
commissionEarned = COMM_2
elseif numBedrooms == 1 then
commissionEarned = COMM_1
elseif numBedrooms == 0 then commissionEarned = COMM_STUDIO
else
output "Invalid number of bedrooms" endif
output salesPersonID, salesPersonName, commissionEarned // Fixed: Using salesPersonName
return
finish()
output "End of report"
return
What we have done is:
Changes to the getReady() function:
Fixed the input: The code now takes the salesperson's ID as input instead of just displaying it.
Moved inside the loop: The getReady() function is now called repeatedly so you can enter information for multiple salespeople without restarting the program.
Change to the detailLoop() function:
Consistent name: The code now uses the correct variable name (salesPersonName) when displaying the salesperson's name in the output.
Changes to the Declarations section:
Added a new variable: A new variable called commissionEarned was added to store the calculated commission amount.
DEBUG 04-02
start
Declarations
string department
num salesQuarter1ThisYear
num salesQuarter2ThisYear
num salesQuarter3ThisYear
num salesQuarter4ThisYear num salesQuarter1LastYear
num salesQuarter2LastYear
num salesQuarter3LastYear
num salesQuarter4LastYear
num totalThisYear
num totalLastYear
string status
string QUIT = "ZZZZ" // Changed to string housekeeping()
while department <> QUIT compareProfit()
endwhile
finishUp() stop
housekeeping()
output "Enter department name or ", QUIT, " to quit: " // colon for clarity
input department return
compareProfit()
getSalesData()
sumSalesData()
if totalThisYear > totalLastYear then // comparison operator changed
status = "Higher"
elseif totalThisYear < totalLastYear then // comparison operator changed
status = "Lower"
else status = "Same"
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
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 salesQuarter1ThisYear
output "Enter sales for third quarter this year "
input salesQuarter1ThisYear
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 salesQuarter3LastYear
output "Enter sales for third quarter last year "
input salesQuarter3LastYear
output "Enter sales for fourth quarter last year "
input salesQuarter3LastYear
return
sumSalesData()
totalThisYear = salesQuarter1ThisYear + salesQuarter2ThisYear +
salesQuarter2ThisYear + salesQuarter4ThisYear
totalLastYear = salesQuarter2LastYear + salesQuarter2LastYear +
salesQuarter3LastYear + salesQuarter4LastYear
return
finishUp()
output "End of report"
return
What i have made it to correct is:
QUIT is now a word: I changed QUIT to "ZZZZ" because it's gotta be a word to compare with the department name the user types in.
Fixed the > and < signs: Flipped the 'greater than' and 'less than' signs in the profit comparison part so the code actually tells if profits went up or down.
Added a colon for looks: Stuck a colon (:) in the "Enter department name..." message so it's easier to read.
DEBUG 03-04: start
Declarations
string carType
num days
num STD_RATE = 65
num COM_RATE = 40
num SUB_RATE = 30
num DAYS_FOR_DISCOUNT = 7 // Changed from 10 num DISCOUNT_RATE = 0.20
string QUIT = "ZZZZ"
getReady()
while carType <> QUIT detailLoop()
endwhile
finish() stop
getReady()
output "Enter car type (Standard, Compact, Subcompact) or ", QUIT, " to quit: " input carType return
detailLoop()
output "Enter days rented: "
input days
if carType = "Standard" then
rate = STD_RATE
elseif carType = "Compact" then
rate = COM_RATE elseif carType = "Subcompact" then
rate = SUB_RATE
else output "Invalid car type" rate = 0 // No further calculation needed endif if rate <> 0 and days >= DAYS_FOR_DISCOUNT then // Combined conditions discount = rate * DISCOUNT_RATE rate = rate - discount // Calculate final rate
endif
output carType, days, rate // Output the calculated rental rate
output "Enter car type (Standard, Compact, Subcompact) or ", QUIT, " to quit: " input carType return
finish()
output "End of program"
return
Changes made:
discount was wrong: The code said discounts started after 10 days, but it should be 7 days. Fixed that!
Better instructions: Made the car type question clearer, so you know exactly what to type in ("Standard", "Compact", etc.).
Bad car type = no math: Now if you mess up the car type, the program won't try to calculate a price and freak out.
Combining stuff: Squished two checks into one in the discount part to make the code run a bit faster.
Figuring out the discount: Added steps to actually figure out how much money to take off the price if you get the discount.
DEBUG 04-04
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
POSSIBLE SOLUTIONS: Missing Code: There are parts called "detail Loop()" and "housekeeping()" but I don't see how they work. We need to write the actual code for those.
Unused Variable: There's a number called "CUT_OFF2" but it's not doing anything. We should either use it or get rid of it.
Wrong Calculation: The "total" isn't being figured out right. It needs to include the discount. the code does not account for the discount.
Extra Input: The program asks for a name, but then doesn't do anything with it. We can take that out or use the name in the results.