Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Program 1 : Write a Java program that works with the following String array: String [ ] owner = { Alice , Bob,
Program :
Write a Java program that works with the following String array:
String owner Alice "Bob", "Carol";
The program should print all the names in the array, each on its own line.
The program should search the array for a target string and display the search result. See the sample test runs below:
Sample Test Run #:
Who are you looking for? Alice Result: Alice is in the list.
Sample Test Run #:
Who are you looking for? David Result: David is not in the list.
Program :
Write Java program with the following classes:
A class named Car that has the following:
Fields Attributes:
make: A String which holds the make of the car.
Example: Ford
model: A String which holds the model of the car.
Example: Explorer
year: An int which holds the year the car was manufactured.
Example:
Constructor and other Methods:
Constructor: Accepts the car's make, model, and year as arguments.
Accessors and Mutators: For each of the classs attributes.
Other Methods:
o print: Each time it is called, it prints the contents of all the above fields.
A Driver class, which does the following:
Prompt the user for the make, model, and year values of a car to create the Car object.
Create Car objects in an array variable.
Use the print method on these three objects to display their values.
Sample Test Run:
Enter the Make for car #: Ford Enter the Model for car #: Explorer Enter the Year for car #:
Enter the Make for car #: Honda Enter the Model for car #: Accord Enter the Year for car #:
Enter the Make for car #: BMW Enter the Model for car #: Z Enter the Year for car #:
~~~~~~~~~ Printing ~~~~~~~~~~ Number of Cars in the System:
Car
Car
Make:
Model:
Ford
Explorer
Car Year:
Car Car Car
Make: Model: Year:
Honda Accord
Car
Car Car Make:
Model: Year: BMW
Z
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started