Question

In: Computer Science

Design a program in Java to display the following: Car Design Enter the car model's year:...

Design a program in Java to display the following:

Car Design

Enter the car model's year: 1957
Enter the car's make: Chevy
The model year is 1957
The make is Chevy
The speed is 0

Let's see what it can do!!
The speed is,...
5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 125 130 135 140 145 150
STOP! STOP! Let me OUT!
The speed is,...
145 140 135 130 125 120 115 110 105 100 95 90 85 80 75 70 65 60 55 50 45 40 35 30 25 20 15 10 5 0

Whew. I'll just walk from here - thanks.

Solutions

Expert Solution

In case of any query do comment. Please rate answer as well. Thanks

Code:

import java.util.*;
public class Main
{
        public static void main(String[] args) {
                int carModelYear;
                String carMake;
                
                //take input from the user
                Scanner scnr = new Scanner(System.in);
                System.out.print("Enter the car model's year: ");
                carModelYear = Integer.parseInt(scnr.nextLine());
                System.out.print("Enter the car's make: ");
                carMake = scnr.nextLine();
                scnr.close(); //close the scanner
                //print the output as shown
                System.out.println("The model year is " + carModelYear);
                System.out.println("The make is " + carMake);
                System.out.println("The speed is 0");
                System.out.println();
                System.out.println("Let's see what it can do!!");
                System.out.println("The speed is,...");
                //for loop to increase the speed and display it on output window
                for (int i=5;i <=150 ;i+=5 ) 
                {
                    System.out.print(i + " ");
                }
                //asking for stop
                System.out.println("STOP! STOP! Let me OUT!");
                
                System.out.println("The speed is,...");
                //decrease the speed by 5
                for (int i=150;i >=0 ; i-=5 ) 
                {
                    System.out.print(i + " ");
                }
                System.out.println(); //to print a new line
                System.out.println("Whew. I'll just walk from here - thanks.");
        }
}

==============screen shot of the code==========

Output:


Related Solutions

Design a program in Java to display the following: Car Design Enter the car model's year:...
Design a program in Java to display the following: Car Design Enter the car model's year: 1957 Enter the car's make: Chevy The model year is 1957 The make is Chevy The speed is 0 Let's see what it can do!! The speed is,... 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 125 130 135 140 145 150 STOP! STOP! Let me OUT! The...
Design a program that displays the following in Java: Enter the grades for an Essay: Grammer...
Design a program that displays the following in Java: Enter the grades for an Essay: Grammer (must be 30 or less): 40 Grammer (must be 30 or less): 26.3 Spelling (must be 20 or less): 17.4 Correct Length (must be 20 or less): 19 Content (must be 30 or less): 23.5 The recorded scores are: Grammer: 26.3 Spelling: 17.4 Correct Length: 19.0 Content: 23.5 Total score: 86.2 The grade for this essay is B
Design, plan, test, and write a computer program in Java that asks the user to enter...
Design, plan, test, and write a computer program in Java that asks the user to enter 1 number and a String. You will display the first n characters of the string where n is the number entered. For example, if the user enters 3 and java then you will print jav. If they enter 5 and Halloween then you print Hallo. If the user enters a number less than 0 then set the number to 0. Assume the user will...
Write a java program that will first display the following menu: Choose one of the following...
Write a java program that will first display the following menu: Choose one of the following 1- To add 2 double integers 2- To add 2 integer numbers 3- To add 3 double numbers 4- To add 3 integer numbers After reading user’s choice, use a switch case statement to call the corresponding method Void add 1 (double n1, double n2) Void add2() Double add3 (double n1, double n2, double n3) Double add4 ()
Write a java program that does the following: a) The user will enter data such as...
Write a java program that does the following: a) The user will enter data such as client name and client balance. The user can stop inputting data by entering "stop". The program should store the user inputs as a data member of an array. The type of this array is a class named ClientData. Below the output should be displayed by the program. The parts in bold are inputs from the user and not hard coded in the program Client...
Using Java, design a program to let user enter two lists of numbers within the range...
Using Java, design a program to let user enter two lists of numbers within the range [0, 9] from keyboard, you could either use flag to denote end of the list or ask user to enter the list size first and then enter the list numbers. Each of these two lists represents a set (keep in mind that duplicate elements are not allowed in the same set but are allowed between sets), so we have two sets A and B....
Create a program in java with the following information: Design a program that uses an array...
Create a program in java with the following information: Design a program that uses an array with specified values to display the following: The lowest number in the array The highest number in the array The total of the numbers in the array The average of the numbers in the array Initialize an array with these specific 20 numbers: 26 45 56 12 78 74 39 22 5 90 87 32 28 11 93 62 79 53 22 51 example...
Create a JavaFX program in java that does the following items: Display a drawing area of...
Create a JavaFX program in java that does the following items: Display a drawing area of dimension 500 x 400, with a black background. Provides a radio button group to allow the user to select one of the following three colors: red, green, and blue. Upon startup, the red radio button should be selected. Each time the user clicks in the drawing area, a circle of size 10 of the color selected by the radio button group in item 2...
Specifications: Write a Java program called LifeRaft.java that will do all of the following: Display a...
Specifications: Write a Java program called LifeRaft.java that will do all of the following: Display a title Ask the user to enter the following values: The type of plane(Boeing 747 or Airbus A300) The number of passengers on board the Plane The number of crew aboard the plane The maximum number of people that can be carried by one liferaft assuming all the liferafts on the plane are the same size The actual number of liferafts that are available on...
IN C++: Write a program to display the following table. MUST use for-loop Enter the table...
IN C++: Write a program to display the following table. MUST use for-loop Enter the table size: 10 N N^2 Square root of N --------------------------------------------- 1 1 1.00 2 4 1.41 3 9 1.73 ….. 10 100 3.16
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT