I have an assignment that says to write a program that asks the user to enter the day of week. Using nested if...else statements, display output that tells the user about an activity on that particular day this is what I have(keep in mind i'm a rookie):
import javax.swing.JOptionPane; public class Activity { public static void main(String[] args) { String , dayofWeek = ,outputMessageOne,outputMessageTwo,outputMessageThree, outputMessageFour,outputMessageFive,outputMessageSix,outputMessageSeven,Sunday; dayofWeek = JOptionPane.showInputDialog("Enter day of week" ); if (dayofWeek == Sunday) { outputMessageOne = "Today there is nothing going on"; JOptionPane.showMessageDialog( null,outputMessageOne ); }else if (dayofWeek == "Monday") { outputMessageTwo = "Monday Night Football will be on tonight"; JOptionPane.showMessageDialog (null,outputMessageTwo); }else if (dayofWeek == "Tuesday") { outputMessageThree = "Black and White Party tonight at Club Heat"; JOptionPane.showMessageDialog(null, outputMessageThree); }else if (dayofWeek == "Wednesday") { outputMessageFour = "Softball game at Lions Park"; JOptionPane.showMessageDialog(null, outputMessageFour); }else if (dayofWeek == "Thursday") { outputMessageFive = "College Football will be on ESPN tonight"; JOptionPane.showMessageDialog(null, outputMessageFive); }else if (dayofWeek =="Friday") { outputMessageSix = " Party at Venturas Longue "; JOptionPane.showMessageDialog(null,outputMessageSix); }else if (dayofWeek == "Saturday") { outputMessageSeven = "Baseball game at Wolf's Park"; JOptionPane.showMessageDialog(null, outputMessageSeven); }else outputMessageEight = "Your seeing this message because you foolishly misspelled a word or did something wrong"; JOptionPane.showMessageDialog(null, outputMessageEight); } }
I get an error that says outputMessageEight might not have been initialized
Another note when I add a brace after the last else, the program compiles without error but when it runs it just ask the asker for the day of the week and automatically displays outputMessageEight.
What am I doing wrong? Can somebody help me out. I would greatly appreciate it.