In: Computer Science
In the assignment below please fix the errors in each
code. The first code should have a total of 3 erros. The second and
third code should have 4 errors. Thanks
//DEBUG05-01
// This program is supposed to display every fifth year
// starting with 2017; that is, 2017, 2022, 2027, 2032,
// and so on, for 30 years.
// There are 3 errors you should find.
start
Declarations
num year
num START_YEAR = 2017
num FACTOR = 5
num END_YEAR = 30
year = START_YEAR
while year <= END_YEAR
output year
endif
stop
//DEBUG05-02
// A standard mortgage is paid monthly over 30 years.
// This program is intended to output 360 payment coupons
// for each new borrower at a mortgage company.
// Each coupon lists the month number, year number,
// and a friendly mailing reminder.
// There are 4 errors here.
start
Declarations
num MONTHS = 12
num YEARS = 30
string MSG = "Remember to allow 5
days for mailing"
num acctNum
num yearCounter
housekeeping()
while acctNUm <> QUIT
printCoupons()
endwhile
finish()
stop
housekeeping()
print "Enter account number or ", QUIT, " to quit
"
input acctNum
return
printCoupons()
while yearCounter <= YEARS
while monthCounter <=
MONTHS
print acctNum,
monthCounter, yearCounter, MSG
monthCounter =
monthCounter + 1
endwhile
endwhile
output "Enter account number or ", QUIT, " to quit
"
input acctNum
return
finish()
output "End of job"
return
//DEBUG05-03
// This program displays every combination of three-digits
// There are 4 errors here.
start
Declarations
num digit1 = 0
num digit2 = 0
num digit3 = 0
while digit1 <= 9
while digit2 <= 9
while digit3 <=
9
output digit1, digit2, digit3
digit1 = digit1 + 1
endwhile
digit2 = digit2 +
1
endwhile
digit3 = digit3 + 1
endwhile
stop
Note: In the below codes , error coorection have been shown by the bold letteres.
Debug 1:
start
Declarations
num year
num START_YEAR = 2017
num FACTOR = 5
num END_YEAR = START_YEAR +
FACTOR*29
year = START_YEAR
while year <= END_YEAR
year=year + 5
output year
endwhile
stop
Debug 2:
start
Declarations
num MONTHS = 12
num YEARS = 30
string MSG = "Remember to allow 5
days for mailing"
num acctNum
num
yearCounter=1
num monthCounter=1
housekeeping()
while acctNum<> QUIT
printCoupons()
endwhile
finish()
stop
housekeeping()
print "Enter account number or ", QUIT, " to quit
"
input acctNum
return
printCoupons()
while yearCounter <= YEARS
while monthCounter <=
MONTHS
print acctNum,
monthCounter, yearCounter, MSG
monthCounter =
monthCounter + 1
endwhile
yearCounter= yearCounter+1
endwhile
output "Enter account number or ", QUIT, " to quit
"
input acctNum
return
finish()
output "End of job"
return
Debug 3:
start
Declarations
num digit1 = 0
num digit2 = 0
num digit3 = 0
while digit1 <= 9
while digit2 <= 9
while digit3 <=
9
output digit1, digit2, digit3
digit3 = digit3 + 1
endwhile
digit2 = digit2 +
1
digit3 = 0
endwhile
digit1 = digit1 +
1
digit2= 0
endwhile
stop
Note: if you know the "c" language and want to implement these codes on your own, the screenshots of code in the "c" language is attached for the first and last question, otherewise leave this portion.