Question: DEBUG #2 Each file starts with some comments that describe the problem. Comments are lines that begin with two slashes (//). Following the comments, each

DEBUG #2 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 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 num salesQuarter1ThisYear num salesQuarter2ThisYear num salesQuarter3ThisYear num salesQuarter4ThisYear num salesQuarter1LastYear num salesQuarter2LastYear num salesQuarter3ThisYear 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 dept return

compareProfit() getSalesData() sumSalesData() if totalThisYear = totalLastYear then status = "Higher" else if totalThisYear <= totalLastYear then status = "Lower" else 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 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

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!