Code a conditional operator (ternary operator) that prints Dinner at Silo! when gourmetDining is Y or y,
Fantastic news! We've Found the answer you've been seeking!
Question:
Code a conditional operator (ternary operator) that prints “Dinner at Silo!” when gourmetDining is ‘Y’ or ‘y’, and “Dinner at Luciano Family Pizzeria” when it is anything else. Assume gourmetDining has already been declared and initialized.
I used:
gourmetDining = keyboard.nextLine().charAt(0);
System.out.printf(gourmetDining == 'Y' ? "Dinner at Silo!" : "Dinner at Luciano Family Pizzeria");
BUT: the instructions say 'y' OR 'Y', and I don't know how to make that happen. Thanks in advance!
Related Book For
A First Course in Differential Equations with Modeling Applications
ISBN: 978-1305965720
11th edition
Authors: Dennis G. Zill
Posted Date: