forked from Joyounger/Introduction-to-Java-Programming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestScanner.java
More file actions
executable file
·27 lines (21 loc) · 792 Bytes
/
TestScanner.java
File metadata and controls
executable file
·27 lines (21 loc) · 792 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; //Scanner is in java.util
public class TestScanner
{
static public void main(String args[])
{
//create a scanner
Scanner scanner = new Scanner(System.in);
//prompt the user to enter an integer
System.out.print("enter an integer: ");
int intValue = scanner.nextInt();
System.out.println("you enter the integer " + intValue);
//prompt the user to enter a doube value;
System.out.print("enter a double value: ");
double doubleValue = scanner.nextDouble();
System.out.println("you enter the double " + doubleValue);
//prompt the user to enter a doube value;
System.out.print("enter a string without space: ");
String string = scanner.next();
System.out.println("you enter the string " + string);
}
}