Purchase Solution

Correct the program.

Not what you're looking for?

Ask Custom Question

// Program accepts a student's year in school (1 to 4)
// and the number of cans collected for a recycling drive.
// Output is a report that lists each class year and
// the total number of cans collected by that class.
start
num year
num cans
num SIZE = 4
num collected[SIZE] = 0, 0, 0
string HEAD1 = "Can Recycling Report"
string HEAD2 = "Year Cans Collected"
input year, cans
while not eof
collected[year] = collected[year - 1] + cans
input year, cans
endwhile
print HEAD1
print HEAD2
year = 1
while year <= year
output year, collected[year - 1]
endwhile
stop

Purchase this Solution

Solution Summary

Comments are inserted around the corrections to explain what was corrected and the need for that.

Solution Preview

Please find my comments, marked with #, inserted in your program below, along with the corrections. Kindly compare the following corrected program with your original program in case you are not clear about what is corrected (though # comments should make it clear anyway).

// Program accepts a student's year in school (1 to 4)
// and the number of cans collected for a recycling drive.
// Output ...

Purchase this Solution


Free BrainMass Quizzes
Basic UNIX commands

Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.

Word 2010: Tables

Have you never worked with Tables in Word 2010? Maybe it has been a while since you have used a Table in Word and you need to brush up on your skills. Several keywords and popular options are discussed as you go through this quiz.

C# variables and classes

This quiz contains questions about C# classes and variables.

Java loops

This quiz checks your knowledge of for and while loops in Java. For and while loops are essential building blocks for all Java programs. Having a solid understanding of these constructs is critical for success in programming Java.

Basic Computer Terms

We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.