Java
Problem 01
Welcome to Java!
- Print
Hello, World.
on the first line - Print
Hello, Java.
on the second line
Solution
public class Solution {
public static void main(String[] args) {
System.out.println("Hello, World");
System.out.println("Hello, Java");
}
}
Problem 02
Java Stdin and Stdout
Read 3 integers from stdin and then print them to stdout. Each integer must be printed on a new line. To make the problem a little easier, a portion of the code is provided for you.
import java.util.*;
public class Solution {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int a = scan.nextInt();
// Complete this line
// Complete this line
System.out.println(a);
// Complete this line
// Complete this line
}
}
Input Format
42
100 125
Sample Output
42
100 125
Solution
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);
}
}