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. I am doing this in JAVA Programming

Respuesta :

Limosa

Answer:

The following code is written in java programming language:

//set if statement

if (((modelYear >= 1999) && (modelYear <= 2002) && (modelName == "Extravagant")) || ((modelYear >= 2004) && (modelYear <= 2007) && (modelName == "Guzzler")))

{

recalled = true;    //initialized Boolean value

}

else      //set else statement

{

recalled = false; ////initialized Boolean value

}

Explanation:

Here, we set the if statement and set condition, if the value of modelYear is greater than equal to 1999 and less that equal to 2002 and modelName is equal to "Extravagant" or the value of modelYear is greater than equal to 2004 and less than equal to 2007 and the model year is equal to "Guzzler", than "recalled" initialized to "true".

Otherwise "recalled" initialized to "true".

ACCESS MORE
EDU ACCESS
Universidad de Mexico