-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScan.java
More file actions
36 lines (27 loc) · 1006 Bytes
/
Copy pathScan.java
File metadata and controls
36 lines (27 loc) · 1006 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
32
33
34
35
36
import java.util.Scanner;
public class Scan {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
// Taking a string input
System.out.print("Enter a string: ");
String str = scanner.nextLine();
System.out.println("You entered: " + str);
// Taking an integer input
System.out.print("Enter an integer: ");
int integer = scanner.nextInt();
System.out.println("You entered: " + integer);
// Taking a double input
System.out.print("Enter a double: ");
double dbl = scanner.nextDouble();
System.out.println("You entered: " + dbl);
// Taking a boolean input
System.out.print("Enter a boolean: ");
boolean bool = scanner.nextBoolean();
System.out.println("You entered: " + bool);
// Taking a single word input
System.out.print("Enter a single word: ");
String word = scanner.next();
System.out.println("You entered: " + word);
scanner.close();
}
}