Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 102 Computers In Context (Multimedia)‏ 03 / 25 / 2009 Instructor: Michael Eckmann.

Similar presentations


Presentation on theme: "CS 102 Computers In Context (Multimedia)‏ 03 / 25 / 2009 Instructor: Michael Eckmann."— Presentation transcript:

1 CS 102 Computers In Context (Multimedia)‏ 03 / 25 / 2009 Instructor: Michael Eckmann

2 Michael Eckmann - Skidmore College - CS 102 - Spring 2009 Today’s Topics Questions/comments? Chapter 5 –Drawing our own pictures Getting input from the user

3 Michael Eckmann - Skidmore College - CS 102 - Spring 2009 Drawing our own pictures Let's finish our program from last time to create an image exactly like: greyeffect.jpg

4 Michael Eckmann - Skidmore College - CS 102 - Spring 2009 Getting input Many programs request information from the user at runtime. Your project (which will be assigned shortly) will require this too. input is a function that takes as a parameter a string that will be displayed to the user and provides an entry field for the user to enter his/her input. input returns what the user entered. So, how do you think we call this function?

5 Michael Eckmann - Skidmore College - CS 102 - Spring 2009 Getting input Many programs request information from the user at runtime. Your project (which will be assigned shortly) will require this too. input is a function that takes as a parameter a string that will be displayed to the user and provides an entry field for the user to enter his/her input. input returns what the user entered. So, how do you think we call this function? Example: userInput = input(“Enter a number please:”)‏

6 Michael Eckmann - Skidmore College - CS 102 - Spring 2009 Getting input input will allow the user to enter many different kinds of data including: –Integers –Real numbers –Strings (surrounded by quotes)‏

7 Michael Eckmann - Skidmore College - CS 102 - Spring 2009 JES Input functions There are some JES input functions that have some built-in error checking: requestNumber requestInteger requestString These functions all take in a String as a parameter and display it to the user and also provide an entry field for the user to enter their input. However, what the user enters is verified to be the correct type (integer, number, string). For example if the user enters Hello for requestInteger then the function reasks the user for input because s/he did not enter an integer (they entered a string).

8 Michael Eckmann - Skidmore College - CS 102 - Spring 2009 JES Input functions There's another JES input function: requestIntegerInRange This function takes in three parameters: a String which is displayed, and two integers (the minimum and maximum integers that you want the user to enter). What if we didn't have requestIntegerInRange but we only had requestInteger. Could we write a function that mimicked the behaviour of requestIntegerInRange?

9 Michael Eckmann - Skidmore College - CS 102 - Spring 2009 Let's write a menu Let's write a function that displays many options to the user like: 1. Multiply 2. Divide 3. Add 4. Subtract 5. Quit and allows the user to enter an option and performs the chosen functionality.


Download ppt "CS 102 Computers In Context (Multimedia)‏ 03 / 25 / 2009 Instructor: Michael Eckmann."

Similar presentations


Ads by Google