(CIS110 -Cmptr Prgrmmng Dsgn) Week 4 Assignment

(CIS110 -Cmptr Prgrmmng Dsgn) Week 4 Assignment - Input...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Exercise Math Quiz p. 254 Constant Integer MAX_QUESTIONS = 5 For counter = 1 to MAX_QUESTIONS Call giveQuiz() End For Module giveQuiz() Declare Integer num1 = random(1,250) Declare Integer num2 = random(1,250) Declare Integer response Declare Integer answer Display num1, “+”, num2, “=” Input response Set answer = sum (num1, num2) If response == answer Then Display “Congratulations !” Else Display “The Correct Answer is”, answer End If End Module
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Function Integer sum (firstNumber, secondNumber) Declare Integer result Set result = firstNumber + secondNumber Return result End Function Exercise Speeding Calculator p.268 // Variables Declare Integer speed Declare Integer speedLimit // Get the driver’s speed. Display “Please enter your driving speed.”
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Input speed // Get the drivers speed limit. Display “Please enter the speed limit.” Input speedLimit // Correct any speed limit errors. While speedLimit < 20 OR > 70 Display “ERROR-The speed limit must be between 20 MPH and 70 MPH.” Display “Please enter again.” Input speedLimit End While // Get MPH over the limit (if any). If speed > speedLimit Then Call mphOver (speed, speedLimit) Else Display “Your speed is not over the speed limit.” End If Module mphOver (driversSpeed, legalLimit) Declare Integer amountOverLimit Set amountOverLimit = driversSpeed – legalLimit Display “You are going”, amountOverLimit, “over the speed limit.” End Module...
View Full Document

This note was uploaded on 01/19/2012 for the course COMPUTER S 100 taught by Professor Brown during the Spring '11 term at Strayer.

Page1 / 3

(CIS110 -Cmptr Prgrmmng Dsgn) Week 4 Assignment - Input...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online