Computer Science Canada

case construct, a problem

Author:  lashari [ Thu Mar 04, 2004 10:49 pm ]
Post subject:  case construct, a problem

in this program when i type "Monday" in the execution window with the capital "M", it displays the message "mow the lawn" otherwise it would not work, can somebody modify this program so that it will work correctly whether or not the dayof the week is entered with a capital letter.

var day : string
put "Enter the day of the week. " ..
get day
case day of
label "Monday" :
put "mow the lawn"
label "Tuesday" :
put "do the laundry"
label "Wednesday" :
put "shop for groceries"
label "Thursday" :
put "vaccuum the carpets"
label "Friday" :
put "wash the windows"
label "Saturday" :
put "wash the car"
label "Sunday" :
put "take a break"
label :
put "That wasn't a day that I recognize."
end case

Author:  zylum [ Thu Mar 04, 2004 11:01 pm ]
Post subject: 

var day : string
put "Enter the day of the week. " ..
get day
case day of
label "Monday","monday" :
put "mow the lawn"
label "Tuesday","tuesday" :
put "do the laundry"

etc...

just put a common and the alternate spelling/caps

-zylum

Author:  Hackster [ Sat Mar 06, 2004 2:53 pm ]
Post subject: 

wow this site has everything, i also need help with case, thanx

Author:  zylum [ Sat Mar 06, 2004 3:21 pm ]
Post subject: 

what exactly is your problem?

Author:  appling [ Wed Mar 10, 2004 8:54 pm ]
Post subject: 

do u mean this?
code:

var day : string
put "Enter the day of the week. " ..
get day
case day of
    label "Monday", "M", "m" :
        put "mow the lawn"
    label "Tuesday", "T", "t" :
        put "do the laundry"
    label "Wednesday", "W", "w" :
        put "shop for groceries"
    label "Thursday", "Th", "th" :
        put "vaccuum the carpets"
    label "Friday", "F", "f" :
        put "wash the windows"
    label "Saturday", "Sa", "sa" :
        put "wash the car"
    label "Sunday", "S", "s" :
        put "take a break"
    label :
        put "That wasn't a day that I recognize."
end case


: