Create two objects of type Car and call the setter methods to set the property of each
Fantastic news! We've Found the answer you've been seeking!
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 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
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date: