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

  1. Create two objects of type Car and call the setter methods to set the property of each object. 
  2.  
  3. Two objects should be filled with this given information.  
  4.  
  5. Car Name Price Quantity Car Category Brand Name
  6. Tigor    34000 1        EV   Tata
  7. Kona     60000 1        EV   Hyundai
  8.  
  9. You have to take each value from the keyboard (Make use of the Scanner class) and set it. 

  10. For example: 

  11. Enter Car name: Tigor 
  12.  
  13. Enter price in US Dollar: 34000

  14. Enter quantity: 1 
  15.  
  16. Enter Car category: EV 

  17. Enter brand name: Tata

  18. Car{CarName='Tigor', price=34000, quantity=1, CarCategory='EV', brandName='Tata'} 
  19.  
  20. Create a arrayList of type Car and add the created Car objects to the defined arraylist. 
  21. Display the items in the arrayList as following using for loop.  
  22. Expected Output: 
  23. ===================================================================== 
  24. Car Name:  Price Quantity Car Category 
  25. Tigor 34000$  1  EV
  26. Kona 60000$ 1  EV
  27. ===================================================================== 
  28. Total Amount =$94000

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

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

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 Programming Questions!