Ask Question
22 January, 07:20

Clunker Motors Inc. is recalling all vehicles in its Extravagant line from model years 1999-2002 as well all vehicles in its Guzzler line from model years 2004-2007. A boolean variable named recalled has been declared. Given a variable modelYear and a String modelName write a statement that assigns true to recalled if the values of modelYear and modelName match the recall details and assigns false otherwise. Do not use an if statement in this exercise!

+5
Answers (1)
  1. 22 January, 08:32
    0
    boolean recalled;

    ((modelYear>=1999 && modelYear=2004 && modelYear<=2007 && modelName=="Guzzler")) ? recalled = true : recalled = false

    Explanation:

    Using a combination of comparison operators and logical operators, the conditions stated in the question is captured in the code snippet with the boolean variable recalled also declared. Since we are not allowed to use the if statement, we have used the conditional or ternary operator that checks if a condition is true executes the statment that follows the question mark else it executes the statement after the full colon.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Clunker Motors Inc. is recalling all vehicles in its Extravagant line from model years 1999-2002 as well all vehicles in its Guzzler line ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers