-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathch_05_input.java
31 lines (29 loc) · 1.11 KB
/
ch_05_input.java
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 ch_05_input {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter a Character : ");
char ch = sc.next().charAt(0);
System.out.println("Character : " + ch);
System.out.println("Enter an Integer : ");
int a = sc.nextInt();
System.out.println("Integer : " + a);
System.out.println("Enter a Float : ");
float f = sc.nextFloat();
System.out.println("Float : " + f);
System.out.println("Enter a Word : ");
String c = sc.next();
System.out.println("Word : " + c);
System.out.println("Enter an Double : ");
double d = sc.nextDouble();
sc.nextLine();
System.out.println("Double : " + d);
System.out.println("Enter a String : ");
String str = sc.nextLine();
System.out.println("String : " + str);
System.out.println("Enter something (check if input is integer) : ");
boolean b = sc.hasNextInt();
System.out.println("Integer?: " + b);
sc.close();
}
}