Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Current Trends In Database Technology Edbt 2004 Workshops Edbt 2004 Workshops Phd Datax Pim P2panddb And Clustweb Heraklion Crete Greece March 2004 Revised Selected Papers Lncs 3268

Authors: Wolfgang Lindner ,Marco Mesiti ,Can Turker ,Yannis Tzitzikas ,Athena Vakali

2005th Edition

3540233059, 978-3540233053

Students also viewed these Databases questions