Ask Question
5 June, 01:47

from model years 1995-1998 and 2004-2006. A bool variable named norecall has been declared. Given an int variable modelYear write a statement that assigns true to norecall if the value of modelYear does NOT fall within the two recall ranges and assigns false otherwise.

+5
Answers (1)
  1. 5 June, 02:09
    0
    Your question is incomplete, here is the complete question with the solution.

    Clunker Motors Inc. is recalling all vehicles from model years 1995 - 1998 and 2004 - 2006. A Boolean variable named norecall has been declared. Given an int variable modelYear, write a statement that assigns true to noRecall if the value of modelYear does NOT fall within the two recall ranges and assigns false otherwise.

    Answer and Step-by-step explanation:

    Given that

    boolean norecall;

    int modelYear;

    We can solve this problem in three ways as given below:

    1st Method: Using If statement

    if ((modelYear > 1994 && modelYear 2003 && modelYear < 2007)) {

    norecall = false; / / this will assign false if the value of the modelYear falls within the two recall ranges

    }else{

    norecall = true; / / this will assign true if the value of the modelYear does NOT falls within the two recall ranges

    }

    2nd Method: Without using If Statement

    (! (modelYear > = 1995) && (modelYear = 2004) && (modelYear < = 2006))

    / / in this line the ymbol "!" shows that if the range is not within the two recall ranges (1995-1998 & 2004-2006) then it will goes down and will assign true to norecall.

    norecall = true;

    3rd Method: Using Conditional Statement

    ((modelYear>=1995 && modelYear = 2004 && modelYear<=2006)) ? norecall = true : norecall = false;
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “from model years 1995-1998 and 2004-2006. A bool variable named norecall has been declared. Given an int variable modelYear write a ...” in 📗 Mathematics 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