I'm trying to write a program here, and in my if-else statement I have String messageToStudent
initialize if taskCompleted == 'y' || taskCompleted == 'Y'
, and in my else statement to initialize it for anything else. however, when I try to compile it says that messageToStudent
may have not been initialized. Now, I thought I made it through the code that ONE of the messageToStudent
strings would initialize, but I guess I was wrong. Here's what I have so far:
if(school == 1) {
System.out.println(name + ", have you started your engineering project yet?");
taskCompleted = scan.nextLine().charAt(0);
if (taskCompleted == 'y' || taskCompleted == 'Y')
messageToStudent = "Good for you! Keep me updated on your progress.";
System.out.println(messageToStudent);
} else {
messageToStudent = "That's not good at all. It's nearly November!";
}
System.out.println(messageToStudent);