I have to write this code where no matter how the user types the day lowercase or uppercase, it should read it, after trying so hard to get it done I'm now facing a new problem which my code only prints the first statement no matter what day I type.
public class W2Lab2 {
public static void main (String []args){
String str = "sunday";
String str2 = "saturday";
String input = str.toLowerCase();
if (input.equals("sunday")) {
System.out.println("Sunday is the last day of the weekend, but the first day of the week.");
}
else if (input.equals("saturday")) {
System.out.println("WEEEE HEEEE! The weekend is here!");
}
else if ( input == "wednesday"){
System.out.println("I survived to the middle of the week.");
}
else if (input == "friday"){
System.out.println("It's still a workday, but I've already checked out for the weekend.");
}
else if ( input == "monday" || input == "tuesday" || input == "thursday"){
System.out.println("It's just another workday. Will the horror ever end?");
}
else {
System.out.println("What do you mean? That doesn't make sense!!");
}
}
}
Please dont be too technical, I get confused easily. I need a little bit of help. thank you.
Aucun commentaire:
Enregistrer un commentaire