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
What option would you choose in order to store the database on a dedicated sql server?
Ganezh [65]
<span>Single processor servers offer high performance and locked-down security for any website or application. Upgrade to a bundle and save on services like backups and DDoS protection.</span>
7 0
3 years ago
Low-level formatting ____. Group of answer choices is different from physical formatting is usually performed by the purchaser o
Drupady [299]

Low-Level formatting is usually performed by the purchaser of the disk.

<h3>What is low-level formatting?</h3>

Low-Level formatting can be defined as is performed at the factory which electronically creates the hard drive tracks and sectors and tests for bad spots on a disk surface.

Low-level formatting is usually performed by the purchaser of the disk device.

Therefore, B is the correct option.

Learn more about Low-level formatting here:

brainly.com/question/13797778

#SPJ1

3 0
2 years ago
16235 to the nearest ten thousand
masha68 [24]
16235 to the nearest ten thousand would be 20,000.

Hope this helps :)
~ Davinia.
7 0
3 years ago
Read 2 more answers
A_ is an object makerfirst program second object third class fourth method ​
liberstina [14]

Answer:

you will use the components object animator whether sjetchware or HTML

5 0
3 years ago
Differentiate between childhood socialization and adulthood socialization ​
AveGali [126]

Answer:

In adolescence, socialization is concerned with the development of overarching values and the self-image. In adulthood, socialization involves more overt and specific norms and behaviors, such as those related to the work role as well as more superficial personality features.

6 0
3 years ago
Other questions:
  • Why is iot architecture important?
    10·1 answer
  • Which word most strongly appeals to pathos?
    15·1 answer
  • What is the main storage device where the computer stores data?
    15·1 answer
  • A technician is configuring a new SOHO multifunction wireless router at a customer's location to provide network access to sever
    7·1 answer
  • What is data? and types ??
    9·2 answers
  • Question # 2 Multiple Choice The _____ method returns an integer between the two provided numbers. It can take the value of eith
    10·2 answers
  • Write a function (subroutine) that inputs a data value in register r0 and returns value in r0. The function returns y 5 a 1 bx 1
    15·1 answer
  • Hiya people. I am a game developer and I need an idea for a new game. If you have any ideas, pls feel free to tell me. Best idea
    6·2 answers
  • Jessie will make and sell the trending Baked California Maki. Her Peso mark up is 5.00. Selling price PHP 15.000. How much will
    7·1 answer
  • When developing an estimate, which of the following items is typically marked up with the highest percentage rate?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!