l Lull Fomat View Help / A high school is holding a recycling competition // Thi
ID: 3715935 • Letter: L
Question
l Lull Fomat View Help / A high school is holding a recycling competition // This program allows a user to enter a student's // year in school (1 through 4) and number of cans collected // Data is entered continuously until the user enters 9 / After headings, output is four lines // one for each school year class start Declarations num year num cans num SIZE = 4 num QUIT9 num collectedArray[SIZE]-0, ?, ? string HEAD! "Can Recycling Report" string HEAD2"YearCans Collected" output "Enter year of student or ", QUIT, " to quit " input year while year QUIT output "Enter number of cans colected input cans collectedArray[year] - collectedArray[year] + cans output "Enter year of student or ", QUIT, to quit input year endwhile output HEAD1 output HEAD2 year 1 while yearSIZE output year, collectedArray[year] year year 1 endwhile stopExplanation / Answer
// Bold text is change one
// A high school is holding a recycling competition
// This program allows a user to enter a student's
// year in school (1 through 4) and number of cans collected
// Data is entered continuously until the user enters 9
// After headings, output is four lines --
// one for each school year class
start
Declarations
num year
num cans
num SIZE = 4
num QUIT = 9
num collectedArray[4]=0,0,0,0
string HEAD1 = "Can Recycling Report"
string HEAD2 = "Year Cans Collected"
output "Enter year of student (1,2, 3,and 4) or ", QUIT, " to quit "
input year
while year <> QUIT
If year = 1 or 2 or 3 or 4
output "Enter number of cans collected "
input cans
// if array starts as year[0],year[1] else prev statement
// collectedArray[year] = collectedArray[year] + cans iscorrect with index starting with 1
collectedArray[year-1] = collectedArray[year-1] + cans
else
output “ Enter correct output(1,2, 3,and 4) or ", QUIT, " to quit ”
End if
output "Enter year of student or ", QUIT, " to quit "
input year
endwhile
output HEAD1
output HEAD2
year = 0 //if index start with 0 else year=1
while year < SIZE // for indesx starting with 1 while year<=SIZE
output year +1 , collectedArray[year]
year = year + 1
endwhile
stop
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.