Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that asks the user how many automobiles are to be described, and

ID: 3529795 • Letter: W

Question

Write a program that asks the user how many automobiles are to be described, and for each automobile it inputs the user's selection of make and color. Then it outputs color and make. Although you could do this easily using a simple procedural program, do it by using a main method in class AutomobileDriver to instantiate an object called auto from a class Automobile. In the Automobile class, do the following: Create a setMake() method. In this method, prompt the user "Input make of auto: ". Store their input into a make variable. Create a setColor() method. In this method, prompt the user "Input color of auto: ". Store their input into a color variable. Create "getter" methods for make and color. Create a printAll() method. In this method, print the color and make of the automobile on one line in accordance to the sample session given below. In the AutomobileDriver class, do the following: Create an instance of Automobile. Call the setMake() method. Call the setColor() method. Call the printAll() method. Be sure your output is similar to the following: How many autos do you want?: 2 Enter make: Honda Enter color: Blue Enter make: Chevy Enter color: Red You have a Blue Honda. You have a Red Chevy.

Explanation / Answer

Below is the working code.I have checked it in eclipse.

-----------------------------------------------------

AutomobileDriver class

---------------------------------------

import java.util.Scanner;


public class AutomobileDriver {


public static void main(String[] args)

{

Scanner scan=new Scanner(System.in);

int size;

System.out.println("How many autos do you want ?");

size=scan.nextInt();

Automobile[] auto=new Automobile[size];

for(int i=0;i<size;i++)

{

auto[i]=new Automobile();

auto[i].setMake();

auto[i].setColor();

auto[i].printAll();

}

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote