creation: 08/01/99; revised 06/01/00, 05/12/03

Fill in the Blanks

Instructions:   This is an ungraded fill-in-the-blank exercise. Each question consists of a sentence with one or two words left out. A button represents the missing word(s). For each question, think of the word or phrase that should fill each blank, then click on the buttons to see if you are correct. No grade is calculated for this exercise.

This exercise reviews Java input and output of floating point numbers.

1.   Both data type long and data type use 64 bits.

2.   Although they have the same number of bits the used in long and double are completely different.

3.   The Java IO package that we will be using is called

4.   With either integer input or floating point input, a string of properly formatted are read which are then to the target numeric type.

5.   The reserved word means is used to say that value in a variable will not change.

6.   To convert a string of characters to a double, use the parseDouble() method of wrapper class

7.   After the input string has been converted, the value may be to a double variable.

8.   Examine the following program, which reads in a line of text, converts it to a double and then writes the double to the monitor. Fill in blanks.

import ; class Echo { public static void main (String[] args) { double value; BufferedReader stdin = new ( new InputStreamReader( ) ); String inData; System.out.println("Enter the data:"); inData = stdin. value = Double.( inData ) ; System.out.println("You entered:" + value ); } }

9.   Examine the following program, which reads in a number and writes the sine of the number to the monitor. Fill in blanks.* ;
class Trig
  public static void main (String[] args) 
    BufferedReader stdin =
            new BufferedReader( new ( ) );
    String inData;
    double    num, sinNum;                      // declaration of two double variables
    System.out.println("Enter the number:");
    inData = stdin.
    num    = Double.parseDouble( ) ;

    sinNum = Math.( num );
    System.out.println("The square of " + inData + " is " + square );

10.   If the characters "1x23" were entered as data for the above program, it would throw a Exception.

End of the Exercise. If you want to do it again, click on "Refresh" in your browser window. Click here to go back to the main menu.