Question: java code 1 - Learn how to use the conditional operator ? : for making decisions within expressions, based on a variable's value. Write an
java code
Learn how to use the conditional operator : for making decisions within expressions, based on a variable's value.
Write an expression using the conditional operator : that evaluates the variable age and prints the message "You are eligible to vote." if age is greater or equal to or prints "You are not eligible to vote." otherwise.
Learn how to use nested ternary operators to simplify conditional statements.
Write a statement that evaluates the int variable ages and prints the following, using the ternary operator:
"Child": years
"Teen": years
"Adult": years
"Senior": years and above
In a new loyalty program for a caf customers are classified into tiers based on the number of coffee cups they've purchased. Each tier rewards customers with different benefits.
Write an expression that evaluates the int variable coffeeCups, and prints one of the following, using the ternary operator:
"None"
"Bronze"
"Silver"
"Gold"
"Platinum"
The following values of coffeeCups define the categories:
None: if the number of coffees is less than
Bronze tier is awarded between cups and
Silver tier is awarded between cups and
Gold tier is awarded between and
Platinum tier is awarded over cups.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
