In: Computer Science
In java
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 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.
public class SafetyFeatures {
public static void main (String [] args) {
int carYear;
carYear = 1991;
*insert code here*
}
}
public class SafetyFeatures {
public static void main(String[] args) {
int carYear;
carYear = 1995;
// checking if the year is
>1961
if (carYear < 1967) {
System.out.println("Probably has few safety features.");
}
// checking if the year is
>1971
if (carYear > 1971) {
System.out.println("Probably has head rests");
}
// checking if the year is
>1991
if (carYear > 1991) {
System.out.println("Probably has anti-lock brakes");
}
// checking if the year is
>2002
if (carYear > 2002) {
System.out.println("Probably has airbags.");
}
}
}
Note : If you like my answer please rate and help me it is very Imp for me