(CIS110 -Cmptr Prgrmmng Dsgn) Week 4 Assignment

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

Info icon This 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
Image of page 1

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

View Full Document Right 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.”
Image of page 2
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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern