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
This is the most flexible way to create a query. Used to create queries that displays only the records that match criteria enter
Pachacha [2.7K]

Answer:

Query Wizard

Explanation:

We can use the Query Wizard to automatically create a selection query, but in this case, we have less control in our details of the query design, it's the fastest way to create a query, even detect some design errors.

Steps to use the Query Wizard

1) In the Queries group on the Create, click Query Wizard

2) Add fields

3) On the last page of the wizard, add a title to the query

6 0
2 years ago
He should identify his various
joja [24]

Answer:

false, that shouldn't be a a priority to identify if they are or not.

Explanation:

3 0
3 years ago
Which of these number formats would you want to apply to a cell showing the total sales for the month? Currency, Number, or Perc
ollegr [7]

Answer:

Currency

Explanation:

Since sales are in money, and currency shows money, Currency is our answer

3 0
3 years ago
Read 2 more answers
You decide to bulk upload your multiple business locations to Google My Business. Some of the locations in your upload were disa
koban [17]

Complete Question: You decide to bulk upload your multiple business locations to Google My Business. Some of the locations in your upload were disapproved. Which two errors can cause this issue? (Choose two.)

A    Missing listing photos

B  Late listing registration

C   Multiple locations in one physical address

D  Too many listing users

E  Incorrect business name

Answer:

C) Multiple locations in one physical address

E) Incorrect business name

Explanation:

Google provides a service called Google My Business which allows users  with the aid of special tools create, update and maintain their business profiles on the internet. In this way, users are able to build free simple websites and publish posts to engage their customers more effectively.

In the process of signing up for this service, new users are required to verify their business names and physical locations, In the given question a user trying to upload multiple business locations will not get approval if he uploads Multiple locations in one physical address or enters an Incorrect business name.

4 0
3 years ago
Generally, websites ending in .edu, .gov, and .org are less likely to be biased, or to show preference toward a certain financia
svetlana [45]

Answer:

True

Explanation:

Domain extensions always appear at the end of a website's address.

It's a means to categorise websites.

.edu domains are used for educational purposes

.gov are restricted to by government entities

.org is largely used by nonprofit websites.

While

.net is derived from the word network, indicating it was originally intended for organizations involved in networking technologies, such as Internet service providers and other infrastructure companies

.biz is intended for registration of domains to be used by businesses

The right domain extension adds credibility and memorability to your website by aligning it with a specific brand purpose.

8 0
3 years ago
Other questions:
  • ______ are single numbers or values, which may include integers, floating-point decimals, or strings of characters.
    10·1 answer
  • A ________ is a virus that is triggered on a certain date.
    11·1 answer
  • If a 120 V appliance requires 15 A to operate, what is the resistance of the appliance?
    10·1 answer
  • The idea behind ____ is that the peripheral can simply be plugged in and turned on, and that the computer should dynamically rec
    10·1 answer
  • 1. Which of the following should NOT be in a tagline?
    12·1 answer
  • Which is technologically backward country? Options United States U K CHILE INDIA
    14·1 answer
  • When a security professional is presented with a contract drawn up by a company's legal department, which allows them to "hack"
    13·1 answer
  • When entering a function or formula in a cell, which is the first character
    15·1 answer
  • Write an algorithm (in pseudocode) for the following Scenario.
    7·1 answer
  • What underlying concept is edge computing based on?
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!