/**
* Code illustrating problem simplest way to fix the
* problem that occurs when trying to obtain a String
* from the keyboard after "enter" has been
* pressed if the order of the data to be obtained
* can be altered.
*
* This is the example we played with in class where I was
* the 105 year old woman earning a million a year
*
*
* @author ???? - modified by Elizabeth Adams
* @version ???? - September 5, 20008
*/
import java.util.Scanner;
public class InputProblemNo
{
public static void main(String[] args)
{
String name;
int age;
double income;
Scanner keyboard;
keyboard = new Scanner(System.in);
// asking for name first instead of at the end
System.out.print ("What is
your name? ");
name = keyboard.nextLine();
//Note the use of the '*' delimiters
to show
// the user what was picked up as name
System.out.println
('*' + name + '*');
System.out.println
( name );
System.out.print
("What
is your age? ");
age = keyboard.nextInt();
System.out.print
("What
is your annual income? ");
income = keyboard.nextDouble();
System.out.println
("Hello
" + name + ". Your age is " + age +
" and your income is $" + income);
}// end main
}// end class