Question

Find Bugs in the pseudocode // 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 wnats

Find Bugs in the pseudocode

// 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 wnats to quit
// 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 collected[SIZE] = 0, 0, 0, 0
     string HEAD1 = "Can Recycling Report"
     string HEAD2 = "Year      Cans Collected"
  output "Enter year of student or ", QUIT, " to quit "
  input year
  while year <> QUIT
     output "Enter number of cans collected "
     input cans
     collected[year] = collected[year] + cans
  endwhile
  output HEAD1
  output HEAD2
  while year <= SIZE
     output year, collected[year - 1]
     year = year + 1
  endwhile
stop        

DEBUG06-02.txt

// Program lets user input scores on four tests
// Average is computed and letter grade is determined
// Letter grades are based on 90 for an A, 80 for a B, and so on
start
  string name
  num score
  num NUM_TESTS = 4
  num NUM_RANGES = 5
  num RANGES[NUM_RANGES] = 90, 80, 70, 60, 0
  num QUIT = "ZZZZZ"
  string GRADES[NUM_RANGES] = "A", "B", "C", "D", "F"
  num total
  num average
  num sub
  output "Enter student name or ", QUIT, " to quit "
  input name
  while name <> QUIT
     sub = 0
     while sub < NUM_TESTS
        output "Enter score "
        input score
        total = total + score
     endwhile
     average = total / NUM_TESTS
     sub = 0
     while average < RANGES[NUM_TESTS]
        sub = sub + 1
     endwhile
     letterGrade = GRADES[NUM_TESTS]
     output name, letterGrade
     output "Enter student name or ", QUIT, " to quit "
     input name
  endwhile
stop

DEBUG06-03.txt

// This program counts how many sales are made in each of 5 categories of products
start
  Declarations
     num category
     num SIZE = 5
     num QUIT = 9
     num sales[SIZE] = 0, 0, 0, 0, 0
     string HEAD1 = "Sales"
     string HEAD2 = "Category   Number of Sales"
  output "Enter category ", QUIT, " to quit "
  input category
  while category = QUIT
     if category >= 1 AND category < SIZE then
        sales[category + 1] = sales[category - 1] + 1
     else
        output "Invalid category"
     endif
     output "Enter category ", QUIT, " to quit "
     input category
  endif
  output HEAD1
  output HEAD2
  category = 0
  while category <= SIZE
     output category + 1, sales[category]
     category = category + 1
  endwhile
stop

0 0
Add a comment Improve this question Transcribed image text
Answer #1
DEBUG06-02.txt

// Program lets user input scores on four tests
// Average is computed and letter grade is determined
// Letter grades are based on 90 for an A, 80 for a B, and so on
start
string name
num score
num NUM_TESTS = 4
num NUM_RANGES = 5
num RANGES[NUM_RANGES] = 90, 80, 70, 60, 0
num QUIT = "ZZZZZ"
string GRADES[NUM_RANGES] = "A", "B", "C", "D", "F"
num total
num average
num sub
output "Enter student name or ", QUIT, " to quit "
input name
while name <> QUIT
sub = 0
while sub < NUM_TESTS
output "Enter score "
input score
total = total + score
endwhile
average = total / NUM_TESTS
sub = 0
while average < RANGES[NUM_TESTS]
sub = sub + 1
endwhile
letterGrade = GRADES[NUM_TESTS]
output name, letterGrade
output "Enter student name or ", QUIT, " to quit "
input name
endwhile
stop

DEBUG06-03.txt

// This program counts how many sales are made in each of 5 categories of products
start
Declarations
num category
num SIZE = 5
num QUIT = 9
num sales[SIZE] = 0, 0, 0, 0, 0
string HEAD1 = "Sales"
string HEAD2 = "Category Number of Sales"
output "Enter category ", QUIT, " to quit "
input category
while category = QUIT
if category >= 1 AND category < SIZE then
sales[category + 1] = sales[category - 1] + 1
else
output "Invalid category"
endif
output "Enter category ", QUIT, " to quit "
input category
endif
output HEAD1
output HEAD2
category = 0
while category <= SIZE
output category + 1, sales[category]
category = category + 1
endwhile
stop
answered by: abhi
Add a comment
Answer #2
Greetings,

"Healing By Spiritual Doctors" is a book written by T.S which is now available at Apple stores for only $6.99. This book talks about women role throughout the history of creation and the fact that how powerful or known men have tried to buried their influence throughout the history so that their clear voice not be heard.

After 30 years of research in the science of universe,the writer of this book is trying to show the true role of women in the universe and find their roles in healing! In this book you will see how women as Medium, can heal themselves or others by spiritual doctors. This is a gift from god and the pure spirit who are the guidance of our women Medium. This is the book that need to be read by all women so they learn their inner ability and be able to help our society and humanity!
Hope you too hold our hands and be our guidance in this matter.

Sincerely with love,
Taghi Salahshour
answered by: yangdond
Add a comment
Answer #3
To debug, always keep in your mind the value of variables at any time as the program proceeds, and think of exceptional values a user can enter.
Your program must expect users to enter anything because of human errors.
For example, for the recycling program:

// 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 wnats to quit
// 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 collected[SIZE] = 0, 0, 0, 0
string HEAD1 = "Can Recycling Report"
string HEAD2 = "Year Cans Collected"
output "Enter year of student or ", QUIT, " to quit "
input year what if user enters 6? -5?
while year <> QUIT
output "Enter number of cans collected "
input cans
collected[year] = collected[year] + cans
endwhile
output HEAD1
output HEAD2
what is the value of "year" at this point, (logic requires it to be 0)
while year <= SIZE
output year, collected[year - 1]
year = year + 1
endwhile
stop
answered by: Doctor Who
Add a comment
Know the answer?
Add Answer to:
Find Bugs in the pseudocode // 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 wnats
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Turning this Pseudocode into the described C++ Program? (will include Pseudocode AND Description of the Program...

    Turning this Pseudocode into the described C++ Program? (will include Pseudocode AND Description of the Program below!) Pseudoode: start   Declarations num deptNum num salary num hrsWorked num SIZE = 7 num totalGross[SIZE] = 0 string DEPTS[SIZE] = “Personnel”, “Marketing”,   “Manufacturing”, “Computer Services”, “Sales”, “Accounting”, “Shipping”                                                      getReady()    while not eof detailLoop()    endwhile    finishUp() stop getReady()    output “Enter the department number, hourly salary, and number of hours worked”    input deptNum, salary, hrsWorked return detailLoop()    if deptNum >= 1 AND deptNum...

  • // This application reads sales data for a real estate broker. // The user enters a...

    // This application reads sales data for a real estate broker. // The user enters a record for each of 10 salespeople //    containing the salesperson's name, //    the number of properties sold by that person during the month, //    and the total value of those properties. // The data records are sorted by value so the data for //    the top three salespeople can be displayed. // Modify the program to // (1) enter data for any number of...

  • Program 7 Arrays: building and sorting (100 points) Due: Friday, October 30 by 11:59 PM Overview...

    Program 7 Arrays: building and sorting (100 points) Due: Friday, October 30 by 11:59 PM Overview For this assignment, write a program that will calculate the quiz average for a student in the CSCI 240 course. The student's quiz information will be needed for later processing, so it will be stored in an array. For the assignment, declare one array that will hold a maximum of 12 integer elements (ie. the quiz scores). It is recommended that this program be...

  • Use program control statements in the following exercises: Question 1 . Write pseudocode for the following:...

    Use program control statements in the following exercises: Question 1 . Write pseudocode for the following: • Input a time in seconds. • Convert this time to hours, minutes, and seconds and print the result as shown in the following example: 2 300 seconds converts to 0 hours, 38 minutes, 20 seconds. Question 2. The voting for a company chairperson is recorded by entering the numbers 1 to 5 at the keyboard, depending on which of the five candidates secured...

  • Need code written for a java eclipse program that will follow the skeleton code. Exams and...

    Need code written for a java eclipse program that will follow the skeleton code. Exams and assignments are weighted You will design a Java grade calculator for this assignment. A user should be able to calculate her/his letter grade in COMS/MIS 207 by inputting their scores obtained on worksheets, assignments and exams into the program. A skeleton code named GradeCompute.java containing the main method and stubs for a few other methods, is provided to you. You must not modify/make changes...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT