Question: Create two objects of type Car and call the setter methods to set the property of each object. Two objects should be filled with
- Create two objects of type Car and call the setter methods to set the property of each object.
- Two objects should be filled with this given information.
- Car Name Price Quantity Car Category Brand Name
- Tigor 34000 1 EV Tata
- Kona 60000 1 EV Hyundai
- You have to take each value from the keyboard (Make use of the Scanner class) and set it.
For example:
Enter Car name: Tigor- Enter price in US Dollar: 34000
Enter quantity: 1- Enter Car category: EV
Enter brand name: Tata
Car{CarName='Tigor', price=34000, quantity=1, CarCategory='EV', brandName='Tata'}- Create a arrayList of type Car and add the created Car objects to the defined arraylist.
- Display the items in the arrayList as following using for loop.
- Expected Output:
- =====================================================================
- Car Name: Price Quantity Car Category
- Tigor 34000$ 1 EV
- Kona 60000$ 1 EV
- =====================================================================
- Total Amount =$94000
Step by Step Solution
There are 3 Steps involved in it
here is a Java code to create two objects of type Car and call the setter methods to set the property of each object import javautilScanner class Car ... View full answer
Get step-by-step solutions from verified subject matter experts
