In: Computer Science
Write multiple if statements: If carYear is before 1968, 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 2002, print "Probably has airbags.". End each phrase with period and newline. Ex: carYear = 1995 prints:
Probably has head rests. Probably has anti-lock brakes.
I want the answers in C++ not in java script data type
Source Code:
Output:
Code to Copy (refer above images of code for indentation):
/*include header file*/
#include <iostream>
using namespace std;
/*main function*/
int main()
{
/*variable*/
int y;
/*read car year from user*/
cout<<"Enter carYear: ";
cin>>y;
/*check condition and print respective message*/
if(y<1968)
cout<<"Probably has few
safety features."<<endl;
if(y>1971)
cout<<"Probably has head
rests."<<endl;
if(y>1991)
cout<<"Probably has anti-lock
brakes."<<endl;
if(y>2002)
cout<<"Probably has
airbags."<<endl;
return 0;
}