Ask 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 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!

+1
Answers (1)
  1. 18 April, 06:38
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers