-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathKeyboardInput.java
More file actions
31 lines (25 loc) · 984 Bytes
/
Copy pathKeyboardInput.java
File metadata and controls
31 lines (25 loc) · 984 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import java.util.Scanner;
public class KeyboardInput {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
String name;
String city;
int age;
double dubInput;
System.out.println("What is your name?");
name = keyboard.nextLine();
System.out.println("What's your age?");
age = keyboard.nextInt();
keyboard.nextLine(); //consume the newline
System.out.println("What's your real number?");
dubInput = keyboard.nextDouble();
keyboard.nextLine();
dubInput *= 2; //dubInput = dubInput * 2;
System.out.println("What city do you live in?");
city = keyboard.nextLine();
System.out.println("Hello, " + name);
System.out.println("age is " + age);
System.out.println("city is " + city);
System.out.println("Twice your number is " + dubInput);
}//end main
}