-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserInput.java
More file actions
27 lines (22 loc) · 870 Bytes
/
UserInput.java
File metadata and controls
27 lines (22 loc) · 870 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
import java.util.Scanner;
public class UserInput{
public static void main(String[] args) {
System.out.println("Talking Input From the User:");
Scanner scn = new Scanner(System.in); // Scanner is a class & new Scanner is a object
// System.out.println("Enter your number 1:");
// int a = scn.nextInt();
// float a = scn.nextFloat();
// System.out.println("Enter your number 2:");
// int b = scn.nextInt();
// float b = scn.nextFloat();
// System.out.println("Your sum of num1 and num2 is:");
// int sum = a + b;
// float sum = a + b ;
// System.out.println(sum);
// boolean b1 = scn.hasNextInt();
// boolean b1 = scn.hasNextFloat(); // has.Next<any datatype>(); it is a method that check this is correct datatype or not.
// System.out.println(b1);
String str = scn.next();
System.out.println(str);
}
}