29.3k views
1 vote
Assume that day is an int variable whose value is 1 or 2 or ... or 7. Write an expression whose value is "sun" or "mon" or ... or "sat" based on the value of day. (So, if the value of day were 4 then the value of the expression would be "wed".).

User Mdmundo
by
2.9k points

1 Answer

7 votes

Answer:

((day==1)?"sun": ((day==2)?"mon": ((day==3)?"tue": ((day==4)?"wed": ((day==5)?"thu": ((day==6)?"fri": ((day==7)?"sat": "invalid")))))))

Step-by-step explanation:

User Navid Farhadi
by
3.4k points