-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScannerObject.java
More file actions
32 lines (25 loc) · 990 Bytes
/
ScannerObject.java
File metadata and controls
32 lines (25 loc) · 990 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
import java.util.Scanner;
/**
* Created by Melissa on 14/04/2017.
*/
public class ScannerObject {
public static void main(String[] args) {
// Create a Scanner Object
Scanner input = new Scanner(System.in);
System.out.print("Enter a byte value: ");
byte byteValue = input.nextByte();
System.out.print("Enter a short value: ");
short shortValue = input.nextShort();
System.out.print("Enter an int value: ");
int intValue = input.nextInt();
System.out.print("Enter a long value: ");
long longValue = input.nextLong();
System.out.print("Enter a float value: ");
float floatValue = input.nextFloat();
System.out.println("byteValue: " + byteValue);
System.out.println("shortValue: " + shortValue);
System.out.println("intValue: " + intValue);
System.out.println("longValue: " + longValue);
System.out.println("floatValue: " + floatValue);
}
}