Está en la página 1de 2

Answer Key

HW #14
Multiple Choice, True or False, Program Exercises #4
Multiple Choice
1. B
2. D
3. A
4. C
5. D
6. B
7. C
8. B
9. A
10. A
True or False
1. False
2. True
3. True
4. False
5. False
Programming Exercises
#4
//This program will allow the client to enter two numbers and then return the largest value
back to the client.
Module Main ( )
//Local variables
Declare Integer firstNumber, secondNumber
//Display an introductory message to the program
Call showIntro ( )
// Get the numbers from the user
Call getNumbers ( )
//Determine the larger number.
Declare String largest
Set largest = max (firstNumber, secondNumber)
//Display the result

Display largest
End Module
// The showIntro module displays an introduction statement
Module showIntro ( )
Display "This program will compare two numbers that you enter and return the
larger value."
End Module
//The getNumbers module has the user enter two numbers and stores them
//in the firstNumber and the secondNumber reference variables
Module getNumbers (Integer Ref firstNumber, Integer Ref secondNumber)
Display "Enter the first number."
Input firstNumber
Display "Enter the second number."
Input secondNumber
End Module
//The max function determines which of the numbers are larger or if they are equal
Function String max (Integer num1, Integer num2)
Declare String result
If num1 > num2 Then
result = num1, is the larger number.
Else If num2 > num1
result = num2, is a larger number.
Else result = the numbers are equal
End Function

También podría gustarte