Answered

Write multiple if statements

If carYear is before 1967,

print "Probably has few safety features." (without quotes)

If after 1971, print "Probably has head rests. If after 1991, print ,Probably has anti-lock brakes."

If after 2000, print "Probably has airbags. End each phrase with period and newline. Ex: carYear 1995 prints

Probably has head rests. Probably has anti-lock brakes. carYear-1970 Your solution goes here / if(carYear < 1968) System.out.println("Probably has a few safety features.") System.out.println("Probably has seat belts.") System.out.println("Probably has electronic stability control.") System.out.println("Probably has aibags."); 12 13 if(carYear 1970) 15 17 18 if(carYear 1990) if(carYear 2001) 20 21 23 24 25 Check Try again X One possible solution includes four if statements, one for each possible year X Testing for correct output for 1967 Output differs.

Answer :

Code:

#include <iostream>

using namespace std;

int main()

{

  int Car_Year;

  cout<<"Please Enter the Car Model."<<endl;

  cin>>Car_Year;    

 if (Car_Year<1967)

 {

cout<<"Few safety features."<<endl;

 }

else if (Car_Year>1971 && Car_Year<=1991)

{

cout<<"Probably has head rests."<<endl;

}

else if (Car_Year>1991 && Car_Year<=2000)

{

cout<<"Probably has antilock brakes."<<endl;

}

else if (Car_Year>2000)

{

cout<<"Probably has airbags."<<endl;

  }

else

{

cout<<"Invalid Selection."<<endl;

}

  return 0;

}

Output:

Please Enter the Car Model.

1975

Probably has head rests.

Please Enter the Car Model.

1999

Probably has antilock brakes.

Please Enter the Car Model.

2005

Probably has airbags.

Please Enter the Car Model.

1955

Few safety features.

Explanation:

We were required to implement multiple If else conditions to assign car model year with the corresponding features of the car.

The code is tested with a wide range of inputs and it returned the same results as it was asked in the question.

Other Questions