Ask Question
1 June, 12:46

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!

+3
Answers (1)
  1. 1 June, 14:49
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers