-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStdinandStdout
More file actions
43 lines (30 loc) · 1.13 KB
/
StdinandStdout
File metadata and controls
43 lines (30 loc) · 1.13 KB
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
35
36
37
38
39
40
41
/*Problem 1: read 3 integers from stdin and then print them to stdout. Each integer must be printed on a new line.*/
import java.util.*;
public class Solution {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int a = scan.nextInt();
int b = scan.nextInt();
int c = scan.nextInt();
System.out.println(a);
System.out.println(b);
System.out.println(c);
scan.close();
}
}
//Problem 2: Read an integer, a double, and a String from stdin, then print the values
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int i = scan.nextInt();
double d = scan.nextDouble();
scan.nextLine();
String s = scan.nextLine();
//s = s + scan.nextLine(); //Question here is why can't we use this line of code instead of the scan.nextLine() below the double
// Write your code here.
System.out.println("String: " + s);
System.out.println("Double: " + d);
System.out.println("Int: " + i);
}
}