Thursday
May 23, 2013

# Homework Help: programming logic

Posted by tina on Sunday, April 15, 2012 at 12:19am.

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
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
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 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
category = 0
while category <= SIZE
output category + 1, sales[category]
category = category + 1
endwhile
stop

• programming logic - MathMate, Sunday, April 15, 2012 at 7:50am

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
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

• programming logic - Anonymous, Thursday, April 26, 2012 at 4:29pm

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
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 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
category = 0
while category <= SIZE
output category + 1, sales[category]
category = category + 1
endwhile
stop

• programming logic - ts, Thursday, June 28, 2012 at 7:41am

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

Related Questions

CIS - Draw a flowchart or write pseudocode to represent the logic of a program ...
Logic and Design - I need help with pseudocode, and any help regarding forming ...
IT Fundmentals of Programming w/ Algoriths & Logic - How would I write an ...
Computer programming - Sorting is a common operation used in programming. ...
computer science - Your goal is to solve the following programming lab activity...
Pseudocode programming - I need a currency conversion application. It does not ...
Programming (CSI Programming Logic and Design) - Create a program that outputs a...
Programming (CSI 150 Programming Logic and Design) - Create a program that ...
Computer Programing & Logic Design - Submit pseudocode and a flowchart for ...
Computer Programing & Logic Design - Submit pseudocode and a flowchart for ...