Question

In: Computer Science

In java Write multiple if statements: If carYear is before 1967, print "Probably has few safety...

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*

}
}

Solutions

Expert Solution

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


Related Solutions

Write multiple if statements: If carYear is before 1967, print "Probably has few safety features." (without...
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 1992, print "Probably has anti-lock brakes.". If after 2000, print "Probably has tire-pressure monitor.". 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 = 1968;
Write multiple if statements: If carYear is before 1968, print "Probably has few safety features." (without...
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
What probably happened that a government decided it needed to print the below banknote? (Write a...
What probably happened that a government decided it needed to print the below banknote? (Write a minimum of 100 words in your answer)
Use LinkedList build-in class (java.util.LinkedList) to write a Java program that has: A. Method to print...
Use LinkedList build-in class (java.util.LinkedList) to write a Java program that has: A. Method to print all elements of a linked list in order. B. Method to print all elements of a linked list in reverse order. C. Method to print all elements of a linked list in order starting from specific position. D. Method to join two linked lists into the first list in the parameters. E. Method to clone a linked list. The copy list has to be...
Write a complete Java program to print out the name bob
Write a complete Java program to print out the name bob
I need it in java. Write a program that will print if n numbers that the...
I need it in java. Write a program that will print if n numbers that the user will input are or not within a range of numbers. For that, your program needs to ask first for an integer number called N that will represent the number of times that will ask for other integer numbers. Right after, it should ask for two numbers that will represent the Min and Max for a range. Lastly. it will iterate N number times...
Write a java program that will take a line of input and go through and print...
Write a java program that will take a line of input and go through and print out that line again with all the word numbers swapped with their corresponding numeric representations (only deal with numbers from one to nine). Sample runs might look like this: Please enter a line of input to process: My four Grandparents had five grandchildren My 4 grandparents had 5 grandchildren without array and methods.
Write a program in Java that initializes an array with ten random integers and then print...
Write a program in Java that initializes an array with ten random integers and then print three lines of output, containing: Every element at an odd index Every odd element All elements in reverse order   The program should use three different methods to implement the functionalities above. Call the primary source file ArrayManipulator.java
In java coding, write a program that will print out a representation of a “W” using...
In java coding, write a program that will print out a representation of a “W” using a character that a user provides.
Write a Java program that accepts a sequence of commands and print out the number of...
Write a Java program that accepts a sequence of commands and print out the number of successful insertions, the number of successful deletions, the number of successful searches (through the “find” command), the number of items remaining in the list after executing all commands and the final contents of the list. Three commands that will be taken as inputs are “insert”, “delete” and “find”. Input Line 1: The number of transactions m on the list, where 1  m 200. Line 2...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT