Printing strings in the same order

Report a typo

Write a program that reads four words from the input and outputs them in the same order, but each in a new line.

Your program should read the four strings using the next() method and print out each input in a new line.

Tip: You don't need to use anything advanced for this task. Simply declare four strings, read the input, and print them.

Sample Input 1:

Hello
Java
Future programmer

Sample Output 1:

Hello
Java
Future
programmer
Write a program in Java 17
import java.util.Scanner;

class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// start coding here

sc.close();
}
}
___

Create a free account to access the full topic