#Output has two lines at the end

3 messages · Page 1 of 1 (latest)

arctic jolt
#

I'm a beginner in Java and I'm entering a contest, the demo contest end in a few minutes but I will just ask for my own sanity. It's meant to take inputs until a double space is inputted, and print mirror pair for pq & bd and ordinary pair for anything else. The issue is that my output has two random empty line of code at the end that I cannot figure out how to get rid of, and that fails me on the tests.

`import java.io.;
import java.util.
;

public class Main {
static ArrayList<String> TF = new ArrayList<String>();
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
String input = "";
do {
input = keyboard.nextLine();
if(input != " ") {
if(input.equals("bd") || input.equals("db") ||input.equals("pq") ||input.equals("qp")) {
TF.add("Mirrored pair");
} else if (input.equals(" ")) {
continue;
}else{
TF.add("Ordinary pair");
}
}
} while(input.equals(" ")==false && input.isEmpty() == false);
System.out.println("Ready.");

    for(int i =0; i<TF.size(); i++) {
        if(TF.get(i).equals("Mirrored pair") || TF.get(i).equals("Ordinary pair")) {
            System.out.println(TF.get(i));
        } else {
            System.exit(0);
        }
    }

}
}`

tough mauveBOT
#

This post has been reserved for your question.

Hey @arctic jolt! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.