User Input
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.
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.
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();
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)
Homework P. 40 # 1 P. 49 #11