It prints out the way the example is shown but then the program terminates. How do I get it to not terminate? I'm not sure if that's part of the task because it doesn't specify but everything seems fine when I run it.
package com.codegym.task.task07.task0727;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
/*
Changing functionality
*/
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
ArrayList<String> list = new ArrayList<String>();
while (true) {
String s = reader.readLine();
if (s.isEmpty()) break;
list.add(s);
if(s.length() % 2 == 0){
System.out.print(s);
System.out.print(" ");
System.out.print(s);
} else {
System.out.print(s);
System.out.print(" ");
System.out.print(s);
System.out.print(" ");
System.out.print(s);
}
}
ArrayList<String> listUpperCase = new ArrayList<String>();
for (int i = 0; i < list.size(); i++) {
String s = list.get(i);
listUpperCase.add(s.toUpperCase());
}
for (int i = 0; i < listUpperCase.size(); i++) {
System.out.println(listUpperCase.get(i));
}
}
}