I'm java beginner, and I wanted to make To-Do list. The problem is I made scanner function with a lot of useless code and the main problem is that, when I click '1' to finish the To-Do list everything works fine, but when I click '0' to continue doing list i get 3 errors in eclipse:
I really want to get rid of that and still practice.
import java.util.Scanner;
public class ToDo {
public static void main(String[] args) {
Scanner input1 = new Scanner(System.in);
System.out.println("Put in task: ");
String task1 = input1.nextLine();
System.out.println("Is that all? ");
double answer1 = input1.nextDouble();
input1.close();
if(answer1 == 1) {
System.out.println("Your tasks are:\n" + task1);
System.exit(0);
} else if(answer1 == 0) {
System.out.println("\n");
}
Scanner input2 = new Scanner(System.in);
System.out.println("Put in task: ");
String task2 = input2.nextLine();
System.out.println("Is that all? ");
double answer2 = input2.nextDouble();
input2.close();
if(answer2 != 0) {
System.out.println("Your tasks are:\n" + task1 + task2);
System.exit(0);
} else if(answer2 != 1) {
System.out.println("\n");
}
}
}