I am taking my first semester of Java programming, and we\'ve just covered the conditional operator (? :) conditions. I have two questions which seem to be wanting me to \"n
I had the same question at my study. Thanks for the info about if
and else
. Would be my choice too except the assignment is asking us specificly to use the conditional operators. so basically they're asking us to write it in an unreadable way.
(credits < 30) ? "freshman" : (credits >= 30 && credits < 60) ?"sophomore" : (credits >= 60 && credits < 90) ? "junior" : "senior"
This was mine and its correct. I am wondering though if there is a shorter piece of code (using only the conditional operators.).
By the way Evan your code was almost good. just missed some brackets around each expression.