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
Write java program that will ask for the user for 2 input lines and print out...
Write java program that will ask for the user for 2 input lines and print out all words that occur 1 or more times on both lines (case sensitive). Write this without arrays and method. Here is a sample run: <Output> Enter two lines to process. The quick brown fox jumps over a lazy dog The fox hound outruns the lazy dog The words that occur on both lines are: The fox lazy dog
Write a Java program that uses nested for loops to print a multiplication table as shown...
Write a Java program that uses nested for loops to print a multiplication table as shown below.   Make sure to include the table headings and separators as shown.   The values in the body of the table should be computed using the values in the heading   e.g. row 1 column 3 is 1 times 3.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT