Explore BrainMass
Share

# Basic Programming: Designing Programs, Class Diagram, Pseudocode, and Designing Applications

This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

Question 1
What is the screen output of the following code segment? Explain the reasoning behind your answer.
Test1 = 70
Test2 = 98
Test3 = 84
NumberOfTests = 3
Average = (Test1 + Test2 + Test3) / NumberOfTests
IF Average >= 90 THEN
Output = "Great job"
Output = "Your average is: ", Average
ELSE
IF Average >= 80 or Average <=89 THEN
Output = "Nice work"
Output = "Your average is: ", Average
ELSE
Output = "You will better next time!"
ENDIF

Question 2
What screen output does the following code segment produce?
p = 2
q = 4
while p < q
r = 1
while r < q
r = r + 1
endwhile
p = p + 1
endwhile

Question 3
Design a program that allows a user to enter 10 numbers, then displays them in the reverse order of their entry. You
must use an Array as your data structure.

Question 4
Design a class named CustomerRecord that holds a customer number, name, and address. Include methods to set
the values for each data field and output the values for each data field. Create the class diagram and write the
pseudocode that defines the class.

Question 5
Design an application in which you declare an array of five numbers and store five values in the array. Write a try block in which you loop to display each successive element of the array, increasing a subscript by one on each pass through the loop. Assume you are working with a language that automatically creates an ArrayIndexOutOfBoundsException when a subscript is not correct for an array. Create a catch block that catches the exception if it is generated and displays the message, "Now you've gone too far."