Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Clunker Motors Inc. is recalling all vehicles from model years 1995-1998 and

ID: 3751003 • Letter: 1

Question

1. Clunker Motors Inc. is recalling all vehicles from model years 1995-1998 and 2004-2006. An int variable named norecall has been declared. Given another int variablemodelYear write a statement that assigns 1 to norecall if the value of modelYear does NOT fall within the two recall ranges and assigns 0 otherwise.

Do not use an if statement in this exercise!

2.Clunker Motors Inc. is recalling all vehicles from model years 2001-2006. An int variable named norecall has been declared. Given an int variable modelYear write a statement that assigns 1 to norecall if the value of modelYear does NOT fall within the recall range and assigns 0 otherwise.

Do not use an if statement in this exercise!

3.Clunker Motors Inc. is recalling all vehicles from model years 2001-2006. An int variable named recalled has been declared. Given an int variable modelYear write a statement that assigns 1 to recalled if the value of modelYear falls within the recall range and assigns 0 otherwise.

Do not use an if statement in this exercise!

4.Clunker Motors Inc. is recalling all vehicles from model years 1995-1998 and 2004-2006. An int variable named recalled has been declared. Given an int variablemodelYear write a statement that assigns 1 to recalled if the value of modelYear falls within the two recall ranges (the first range being 1995-1998, the second range being 2004-2006) and assigns 0 otherwise.

Do not use an if statement in this exercise!

(ALL IN C LANGUAGE)

Explanation / Answer

Solution for 1. We are using switch case in place of if-else.

#include<stdio.h>
int main()
{
   int norecall, modelYear,choice;
   do
   {
       printf("Enter the value for modelYear");
       scanf("%d",&modelYear);
       switch(modelYear)
       {
           case 1995:
               norecall=0;
               break;
           case 1996:
               norecall=0;
               break;
           case 1997:
               norecall=0;
               break;
           case 1998:
               norecall=0;
               break;
           case 2004:
               norecall=0;
               break;
           case 2005:
               norecall=0;
               break;
           case 2006:
               norecall=0;
               break;
           default:
               norecall=1;
       }
       printf(" The value of variable norecall is %d for modelYear %d ",norecall,modelYear);
       printf("Enter 1 to check another car information OR Enter any other input to exit ");
       scanf("%d",&choice);
   }while(choice==1);

   return 0;
}

###The question 2 is similar to question 1, only difference is in the range. Solution code is::

#include<stdio.h>
int main()
{
   int norecall, modelYear,choice;
   do
   {
       printf("Enter the value for modelYear");
       scanf("%d",&modelYear);
       switch(modelYear)
       {
           case 2001:
               norecall=0;
               break;
           case 2002:
               norecall=0;
               break;
           case 2003:
               norecall=0;
               break;
           case 2004:
               norecall=0;
               break;
           case 2005:
               norecall=0;
               break;
           case 2006:
               norecall=0;
               break;
           default:
               norecall=1;
       }
       printf(" The value of variable norecall is %d for modelYear %d ",norecall,modelYear);
       printf("Enter 1 to check another car information OR Enter any other input to exit ");
       scanf("%d",&choice);
   }while(choice==1);

   return 0;
}

Solution for question 3::

#include<stdio.h>
int main()
{
   int recalled, modelYear,choice;
   do
   {
       printf("Enter the value for modelYear");
       scanf("%d",&modelYear);
       switch(modelYear)
       {
           case 2001:
               recalled=1;
               break;
           case 2002:
               recalled=1;
               break;
           case 2003:
               recalled=1;
               break;
           case 2004:
               recalled=1;
               break;
           case 2005:
               recalled=1;
               break;
           case 2006:
               recalled=1;
               break;
           default:
               recalled=0;
       }
       printf(" The value of variable norecall is %d for modelYear %d ",norecall,modelYear);
       printf("Enter 1 to check another car information OR Enter any other input to exit ");
       scanf("%d",&choice);
   }while(choice==1);

   return 0;
}

Solution for question 4:::

#include<stdio.h>
int main()
{
   int recalled, modelYear,choice;
   do
   {
       printf("Enter the value for modelYear");
       scanf("%d",&modelYear);
       switch(modelYear)
       {
           case 1995:
               recalled=1;
               break;
           case 1996:
               recalled=1;
               break;
           case 1997:
               recalled=1;
               break;
           case 1998:
               recalled=1;
               break;
           case 2004:
               recalled=1;
               break;
           case 2005:
               recalled=1;
               break;
           case 2006:
               recalled=1;
               break;
           default:
               recalled=0;
       }
       printf(" The value of variable norecall is %d for modelYear %d ",norecall,modelYear);
       printf("Enter 1 to check another car information OR Enter any other input to exit ");
       scanf("%d",&choice);
   }while(choice==1);

   return 0;
}

###Feel free to ask any doubt.