#how to compare if a string has certain value?

18 messages · Page 1 of 1 (latest)

signal parrot
#

I have to make a program that depending the day of the week tells me to rest or study, I made an input feature to ask me for the day so I can write for example "monday", I wanna be able to use an if and inside the condition ask "day.contains("Monday") and if so then print study. this is the code I made for now

import java.util.Scanner;

public class main {

public static void main(String[] args) {
    
    Scanner myObj = new Scanner(System.in);
    String day;
    System.out.println("Please specify a day"); 
    day = myObj.nextLine();   
       
    if (day.contains("Monday"){
    System.out.println("Good day.");
    }
    
}

}

cosmic slateBOT
#

This post has been reserved for your question.

Hey @signal parrot! Please use /close or the Close Post button above when you're finished. 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.

turbid forge
#

so what's the issue..?

#

i can see you're using the dia variable which doesn't exist, but what's the actual question?

signal parrot
#

changed it to english

turbid forge
#

but what's the actual issue

#

what are you asking for

signal parrot
#

this is what it says

turbid forge
#

oh right

#

missing )

#

you're opening the if (, but not closing it

signal parrot
#

a

#

ty that was dumb SkullPixel

#

thanks for the time and help

cosmic slateBOT
# signal parrot thanks for the time and help

If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.