moggiek
asked on
Switch strings
Hi there
I'm trying to write a program where I can enter a day of the week, and feedback whether its falls during the week or weekend. I want to use a switch statement. Can you tell me how I convert the string so that I can use it in the switch?
I'm trying to write a program where I can enter a day of the week, and feedback whether its falls during the week or weekend. I want to use a switch statement. Can you tell me how I convert the string so that I can use it in the switch?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hrmm... I thought the rule was no code-blocks (i.e. doing the program for them), but we can give general advice/code snippets? (https://www.experts-exchange.com/Programming/Programming_Languages/Java/help.jsp#hi130)
Meh, my only comment would be that you could also use if-statements:
if (dayInput.equals("Sunday") ){dayInt = 1;}
else if (dayInput.equals("Monday") ){dayInt = 2;}
etc.
Meh, my only comment would be that you could also use if-statements:
if (dayInput.equals("Sunday")
else if (dayInput.equals("Monday")
etc.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
-I hate to be nosy, but, it sounds like POSSIBLE homework. Which we're not alowed to help you with.
;) Just so you know
[r.D]