Ask Question
3 September, 07:14

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.

+2
Answers (1)
  1. 3 September, 07:31
    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?
Get 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 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