Link to home
Start Free TrialLog in
Avatar of moggiek
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?
ASKER CERTIFIED SOLUTION
Avatar of Tommy Braas
Tommy Braas
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DrWarezz
DrWarezz

Might I ask, why must it use a "switch" statement?
 -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]
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.
SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial