Java Reference
In-Depth Information
J ava 2
v 5 . 0
Java 2
13 Moving from the BufferedReader to Scanner
v 5 . 0
In Programming Assignment 4, you created an interactive checkbook using the
BufferedReader to accept input in the console window. Convert the program so
that it uses the J2SE version 5.0 Scanner class described on page 148. Import the
java.util.* package. You will change the line of code that constructs an instance of
the BufferedReader to construct an instance of the Scanner class. Change the lines
of code that use the readLine() method to use the nextFloatFloat() method. Insert
comment marks in front of lines that previously parsed the data.
J ava 2
J ava 2
v 5 . 0
14 Moving from Swing to Scanner
v 5 . 0
In Programming Assignment 5, you created an income to debt ratio calculator
with Swing input using dialog boxes. Convert the program so that it uses the
J2SE version 5.0 Scanner class described on page 148. Import the java.util.*
package. You will construct an instance of the Scanner class. Change the lines of
code that use the showInputDialog() method to use the nextDouble() method.
Insert comment marks in front of lines that previously parsed the data.
J ava 2
v 5 . 0
Java 2
15 Input Usability
v 5 . 0
Many businesses conduct usability tests evaluating user interfaces. Your job is to
provide four versions of user input from which a business may select. Choose
any program in this chapter and create the following forms of the same
program:
An application with user input from the BufferedReader at the
command prompt, parsing the data from the readLine() method.
An application with user input from the Scanner class at the command
prompt, using the nextInt() or nextDouble() method.
An application with user input from Swing dialog boxes, parsing the
data from the showInputDialog() method.
An applet with user input from Swing dialog boxes, parsing the data
from the showInputDialog() method.
Add comments to each program describing the kind of input and the methods
used. Print a copy of each program. Demonstrate the program, in execution, to a
classmate. On the back of the printouts, write any feedback about speed, usabil-
ity, or preferences. Turn the printouts in to your instructor.
J ava 2
v 5 . 0
Java 2
16 The Scanner Methods
v 5 . 0
The Scanner method, new to J2SE version 5.0, uses several different methods to
receive user input based on data types. Visit the Sun Microsystems Java API site
at http://java.sun.com/j2se/1.5.0/docs/api/. Use the index to find the Scanner
class. Scroll to the Method Summary. Choose any four methods that begin with
the word, next, and click each one. Read the information provided and write a
brief paragraph about each. Turn the paragraphs in to your instructor.
Search WWH ::




Custom Search