1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Olin [163]
3 years ago
12

Write a Java program to create a class called Cars. The class should include three instance variables: makes (type: String), mod

els (type: String), and years (type: int); and two methods: a constructor() to initialize three variables and a show() to display the information of a car. Write a class called TestCars to test the class Cars. This class should be able to read the makes, models, and years of three cars from screen input, create three-car objects using the constructor() and display each car's make, model, and years using the show(). (5pts)
Computers and Technology
1 answer:
Fiesta28 [93]3 years ago
5 0

Answer:

Explanation:

This code was written in Java. It creates the Cars class with the requested variables and methods. It also creates the TestCars class which asks the user for the necessary inputs and then creates three Cars objects and passes the input values to the constructors. Finally, it uses the show() method on each object to call the information. A test has been created and the output can be seen in the attached image below.

import java.util.Scanner;

class TestCars{

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       System.out.print("Enter Car Make: ");

       String make1 = in.next();

       System.out.print("Enter Car Model: ");

       String model1 = in.next();

       System.out.print("Enter Car Year: ");

       int year1 = in.nextInt();

       System.out.print("Enter Car Make: ");

       String make2 = in.next();

       System.out.print("Enter Car Model: ");

       String model2 = in.next();

       System.out.print("Enter Car Year: ");

       int year2 = in.nextInt();

       System.out.print("Enter Car Make: ");

       String make3 = in.next();

       System.out.print("Enter Car Model: ");

       String model3 = in.next();

       System.out.print("Enter Car Year: ");

       int year3 = in.nextInt();

       Cars car1 = new Cars(make1, model1, year1);

       Cars car2 = new Cars(make2, model2, year2);

       Cars car3 = new Cars(make3, model3, year3);

       car1.show();

       car2.show();

       car3.show();

   }

}

class Cars {

   String makes, models;

   int years;

   public Cars(String makes, String models, int years) {

       this.makes = makes;

       this.models = models;

       this.years = years;

   }

   public void show() {

       System.out.println("Car's make: " + this.makes);

       System.out.println("Car's model: " + this.models);

       System.out.println("Car's year: " + this.years);

   }

}

You might be interested in
The stub: transmits the message to the server where the server side stub receives the message and invokes procedure on the serve
elena55 [62]

Answer:

It does all of these

Explanation:

The stub is able to do all of what we have in this question. It can locate computer connections, locate ports on a computer, transit message to server etc.

in distributed computing, a stub is a piece of code that does the work of converting parameters that are passed between the client and the server at a time of remote procedure call.

The main objective of an RPC is to allow the client to call procedures remotely on another server.

3 0
3 years ago
Swapping two numbers
Tju [1.3M]

Answer:

Swapping two numbers means exchange the values of two variables with each other.

8 0
3 years ago
Which of the following are screen objects used to maintain, view, and print data from a database
amid [387]

Answer:

The correct answer to the following question will be "A spreadsheet".

Explanation:

  • A spreadsheet is a software device used to access and stores data from such a database. The interaction between separate entities (in separate tables) is controlled by their specific columns.
  • It's a programming program for arranging, evaluating and storing data in tabular format.
  • The spreadsheets have been developed as computer-controlled analogs to paper reporting worksheets. The system runs on data decided to enter in table cells.

Therefore, a Spreadsheet is the right answer.

8 0
3 years ago
What is the important safety information found on a boat's capacity plate?
tigry1 [53]
Written on the boat capacity plate that is important for every captain or owner must be knowledgeable about is the maximum allowable total weight and number of passengers. This is to avoid untoward accident due to over capacity and a ticket for unsafe operation by law enforcements. 
6 0
3 years ago
Busca información (nombre, potencia y situación) de los parques eólicos de la Comunidad Valenciana. con más de 40 MW de potencia
Colt1911 [192]
I need this answer too can someone please help us out with the right answer ?!

Explanation:
6 0
2 years ago
Other questions:
  • Which of the following is not a good technique for photographing groups? Visiting the location.
    9·1 answer
  • The difference between a want and a need is a want is not necessary for survival. Things necessary for survival are known as ___
    6·1 answer
  • Drag the tiles to the correct boxes to complete the pairs.
    13·1 answer
  • Which of these is a method of selecting multiple items in Impress or PowerPoint? A. holding down the Ctrl key while clicking ite
    9·2 answers
  • Universal Containers is building an integration between Salesforce and their Accounting system. The integration will utilize out
    8·1 answer
  • Who found the first computer bug in 1947, and invented the concept of a compiler in 1952
    6·1 answer
  • Hey! PLEASE HELP!!!
    12·1 answer
  • True or False <br> Hebrew Bible and the Koran were first written in English.
    15·1 answer
  • What does this mean? And how did I get it?
    12·2 answers
  • Which tools can help you gather information about the processes running on a windows operating system?
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!