Download presentation
Presentation is loading. Please wait.
Published byMatteo Dinner Modified over 9 years ago
1
User Input
2
Why user entry? When we assign values (age = 16), we are making a program static…it never changes. If we ask the user to enter the values, it becomes dynamic…it changes depending on who the user that runs the program.
3
User input The process of reading values into memory is rather complicated in java. (see Appendix B in your textbook) There are already created methods by the author that allows you to read values from the keyboard. The methods are contained in a class called In.
4
class In The class In is not part of java. To use the methods contained in In, obtain a copy of the file In.java, copy it into the directory that you are using for your java programs, and then compile it. To read a value of a particular type, write the name of the appropriate method in an assignment statement i = In.getInt();
5
Class In Other Methods in the class in include: getLong() (to read long value) getFloat() (to read float value) getDouble() (to read long value) getChar() (to read a single character) getString() (to read a string) The methods all assume that each input value is terminated by a newline. (you must press the key after keying in the value)
6
Homework P. 40 # 1 P. 49 #11
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.