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
How does information promote cooperation and Industry please explain​
IRISSAK [1]

Answer:

Provide teams with the resources they need to work together.

Train employees and encourage ongoing learning.

Encourage people to socialize outside of work.

Clarifying roles and setting expectations.

Review individual's talents.

Explanation:

6 0
2 years ago
An IT department receives a shipment of 20 new computers, and Alice has been assigned the task of preparing them for deployment
qaws [65]

Answer:

Asset tracking

Explanation:

Asset tracking refers to the method of tracking physical assets, either by scanning barcode labels attached to the assets or by using tags using GPS, BLE, LoRa, or RFID which broadcast their location. These technologies can also be used for indoor tracking of persons wearing a tag.

7 0
3 years ago
Why is it important to ask an interviewer at least one question at the end of an interview?
tatiyna
Because it, not only does it give you a chance to learn more about the workplace, it also makes you look more interested in the position.
<span />
4 0
3 years ago
Read 2 more answers
Evaluate if the following function is a good candidate to be placed in a library. Why or why not?
Anastaziya [24]

Answer:

No, this would not be a good candidate because it can't be used in creating new programs.

Explanation:

^

8 0
2 years ago
Read 2 more answers
Which of the following are the dimensions of feasibility? Group of answer choices cost, schedule, technical, and organizational
Paha777 [63]

Answer:

"cost, schedule, technical, and organizational feasibility schedule" is the correct option.

Explanation:

A technical feasibility is the study of the concerned about the specifying software and tools which satisfy the users' need. It is also the process of thinking for which business technologies are important to bring labours, transportation, and materials.

An organizational feasibility is the study of the information of the professional background and about the skills which are necessary for the contribution in the business.

7 0
3 years ago
Other questions:
  • What file would you edit to restrict the number of simultaneous logins a user can employ??
    14·1 answer
  • Which Game Is Better &amp; Favorite For You?
    12·2 answers
  • _____ software can help a company manage security, enforce corporate strategies, and control downloads and content streaming fro
    11·1 answer
  • What effect does the interconnectedness of modern media have on society?
    14·2 answers
  • When was internet started in which year​
    13·2 answers
  • Implement a class Product. A product has a name and a price, for example new Product("Toaster", 29.95). Supply methods getName,
    14·2 answers
  • ANSWER ASAP!!!!!
    10·2 answers
  • (14) Click on the
    7·2 answers
  • Work-based learning can be defined as educational experiences that focus on
    6·1 answer
  • Chris needs to modify the default bullets that are used in a nonnumbered list in Word.
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!