Question: Program 1 : Write a Java program that works with the following String array: String [ ] owner = { Alice , Bob,

Program 1:
Write a Java program that works with the following String array:
String[] owner ={"Alice", "Bob", "Carol"};
1. The program should print all the names in the array, each on its own line.
2. The program should search the array for a target string and display the search result. See the sample test runs below:
Sample Test Run #1:
Who are you looking for? Alice Result: Alice is in the list.
Sample Test Run #2:
Who are you looking for? David Result: David is not in the list.
Program 2:
Write Java program with the following classes:
A class named Car that has the following:
Fields (Attributes):
1. make: A String which holds the make of the car.
Example: Ford
2. model: A String which holds the model of the car.
Example: Explorer
3. year: An int which holds the year the car was manufactured.
Example: 2022
Constructor and other Methods:
1. Constructor: Accepts the car's make, model, and year as arguments.
2. Accessors and Mutators: For each of the classs attributes.
3. 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:
1. Prompt the user for the make, model, and year values of a car to create the Car object.
2. Create 3 Car objects in an array variable.
3. Use the print method on these three objects to display their values.
Sample Test Run:
Enter the Make for car #1: Ford Enter the Model for car #1: Explorer Enter the Year for car #1: 2022
Enter the Make for car #2: Honda Enter the Model for car #2: Accord Enter the Year for car #2: 2011
Enter the Make for car #3: BMW Enter the Model for car #3: Z3 Enter the Year for car #3: 2001
~~~~~~~~~ Printing ~~~~~~~~~~ Number of Cars in the System: 3
--
Car
Car ---
Make:
Model: ------
Ford
Explorer -
Car Year: 2022
--
Car Car Car ---
Make: Model: Year: ------
Honda Accord 2011-
------------
Car
Car Car Make:
Model: Year: BMW
Z32001

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!