-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinput.java
More file actions
34 lines (29 loc) · 961 Bytes
/
Copy pathinput.java
File metadata and controls
34 lines (29 loc) · 961 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
import java.util.Scanner;
class input {
public static void main(String[] args) {
Scanner myObj = new Scanner(System.in);
System.out.println("Enter name, age and salary:");
// String input
System.out.print("Name:");
String name = myObj.nextLine();
// Numerical input
System.out.print("Age:");
int age = myObj.nextInt();
System.out.print("Salary:");
double salary = myObj.nextDouble();
// Output input by user
System.out.println("Name: " + name);
System.out.println("Age: " + age);
System.out.println("Salary: " + salary);
}
}
/*
nextBoolean() Reads a boolean value from the user
nextByte() Reads a byte value from the user
nextDouble() Reads a double value from the user
nextFloat() Reads a float value from the user
nextInt() Reads a int value from the user
nextLine() Reads a String value from the user
nextLong() Reads a long value from the user
nextShort() Reads a short value from the user
*/