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
For this assignment, you will create flowchart using Flowgorithm and Pseudocode for the following program example:
satela [25.4K]

Answer:

The pseudocode is as given below in the explanation while the flow diagram is attached herewith

Explanation:

The pseudocode is as follows

input cust_name, num_texts  

Set Main_bill=5 $;

if the num_texts is less than or equal to 60

Excess_Charge=0;

If the num_texts is greater than 60 and less than or equal to 200

num_text60200 =num_texts-60;

Excess_Charge=0.1*(num_text60200);

else If the num_texts is greater than 60

num_texts200 =num_texts-200;

Excess_Charge=0.25*(num_texts200)+0.1*(200-60);

Display cust_Name

Total_Bill=Main_bill+Excess_Charge;

Total_Bill_after_Tax=Total_Bill*1.12;

6 0
3 years ago
HELP PLEase!!! Which option is an outcome of a project stated in quantifiable terms?
dimulka [17.4K]

Answer: C) a 10 percent increase in efficiency of sales of a particular product line over one year

The term "quantifiable" means that we can attach a number to it. Specifically, a number in which we can do math operations upon it. Something like telephone numbers or serial numbers don't really count as quantifiable entities. They are qualitative variables instead. So you have to be careful what numbers you run into. In this case, "10 percent increase in efficiency" is quantitative and fits what we're after.

A 10% increase corresponds to the multiplier 1.10; for instance, if you had sales of 40 million dollars one year, then a 10% increase is 1.10*40 = 44 million in sales. This is one example where we apply a math operation (specifically multiplication) on the value in question.

4 0
3 years ago
What can you use with your keyboards to narrow your search if you complete an Internet search using a search engine and do not g
pantera1 [17]
I'm pretty sure you would use A.) Quotation Marks.
Hope I helped!
3 0
3 years ago
Is Apple a consumer or luxury brand? Give examples.
Alexus [3.1K]

Answer:

Apple is a luxury brand due to it stable products, expensive products, and its releasing phones costing $1,000 or more and moving its services to the higher end

Explanation:

6 0
3 years ago
Why optical disk is slower than magnetic disk.?​
Mazyrski [523]

Answer:

Answer choices?

Explanation:

5 0
3 years ago
Read 2 more answers
Other questions:
  • Jake and Sarah have an assignment of writing the history of American independence as a team. They divided their work in hait and
    7·2 answers
  • What are 5 actions that you can do to take care of your camera
    14·2 answers
  • An example of an email client is:<br> A.)Yahoo<br> B.)Gmail<br> C.)Outlook<br> D.)All of the Above
    9·1 answer
  • Which of the following must the designer first do in order to create the software in the following scenario? A multimedia design
    14·2 answers
  • a solid state drive is a removable flash memory device that you insert and remove from a slot in a computer, mobile device, or c
    5·1 answer
  • A call center is a _______.<br><br> JIT<br><br> CMA<br><br> CIC<br><br> SFA
    8·1 answer
  • Witch is the correct description of the first act in a classical game story structure
    14·1 answer
  • Write down a scratch program which:
    5·1 answer
  • 1. The advancement of media and information bring society countless opportunities such<br>as...​
    8·1 answer
  • Different the need for external or secondary memory​
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!