Two files are required, a data class named Car and an executable class named TestCar. Class Car (data class, no main method) five instance data members, all private: String make, String model, int year, double price, String color. one static, or class, member named unitsSold assigned a value of zero. Make it public. a no-arg constructor, and another parameterized constructor that sets values in all data members when called. Both constructors should increment the unitsSold static data member. has setters and getters for each data member. a toString() method that returns the state of all data members of a Car instance In Class TestCar must hold a main method and a method named evaluateCars In main: create two Car instances using the parameterized constructor. create a third Car instance with the no-arg constructor use all of the Car class setter methods to assign values to the third Car's data members. use the "array initializer" syntax to make an array to hold these three Car objects. call the method named evaluateCars with the array as its sole argument. Make sure you catch the value returned by evaluateCars. print the value in the unitsSold data member and the value returned by evaluateCars In evaluateCars use a foreach loop to process the array passed in to the method print the state of each Car object using the toString method. calculate the total value of the Car objects in the array. return the total value to main. Example Output make=Lamborghini, model=Aventador, year=2016, price=405000.0, color=yellow make=Honda, model=Odyssey, year=2015, price=33560.0, color=cherry make=Dodge, model=Hellcat, year=2016, price=76500.0, color=orange Your 3 cars are worth $515,060.00
Two files are required, a data class named Car and an executable class named TestCar. Class Car (data class, no main method) five instance data members, all private: String make, String model, int year, double price, String color. one static, or class, member named unitsSold assigned a value of zero. Make it public. a no-arg constructor, and another parameterized constructor that sets values in all data members when called. Both constructors should increment the unitsSold static data member. has setters and getters for each data member. a toString() method that returns the state of all data members of a Car instance In Class TestCar must hold a main method and a method named evaluateCars In main: create two Car instances using the parameterized constructor. create a third Car instance with the no-arg constructor use all of the Car class setter methods to assign values to the third Car's data members. use the "array initializer" syntax to make an array to hold these three Car objects. call the method named evaluateCars with the array as its sole argument. Make sure you catch the value returned by evaluateCars. print the value in the unitsSold data member and the value returned by evaluateCars In evaluateCars use a foreach loop to process the array passed in to the method print the state of each Car object using the toString method. calculate the total value of the Car objects in the array. return the total value to main. Example Output make=Lamborghini, model=Aventador, year=2016, price=405000.0, color=yellow make=Honda, model=Odyssey, year=2015, price=33560.0, color=cherry make=Dodge, model=Hellcat, year=2016, price=76500.0, color=orange Your 3 cars are worth $515,060.00
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
Java
Two files are required, a data class named Car and an executable class named TestCar.
Class Car (data class, no main method)
- five instance data members, all private: String make, String model, int year, double price, String color.
- one static, or class, member named unitsSold assigned a value of zero. Make it public.
- a no-arg constructor, and another parameterized constructor that sets values in all data members when called. Both constructors should increment the unitsSold static data member.
- has setters and getters for each data member.
- a toString() method that returns the state of all data members of a Car instance
In Class TestCar
- must hold a main method and a method named evaluateCars
- In main:
- create two Car instances using the parameterized constructor.
- create a third Car instance with the no-arg constructor
- use all of the Car class setter methods to assign values to the third Car's data members.
- use the "array initializer" syntax to make an array to hold these three Car objects.
- call the method named evaluateCars with the array as its sole argument.
- Make sure you catch the value returned by evaluateCars.
- print the value in the unitsSold data member and the value returned by evaluateCars
- In evaluateCars
- use a foreach loop to process the array passed in to the method
- print the state of each Car object using the toString method.
- calculate the total value of the Car objects in the array.
- return the total value to main.
Example Output
make=Lamborghini, model=Aventador, year=2016, price=405000.0, color=yellow
make=Honda, model=Odyssey, year=2015, price=33560.0, color=cherry
make=Dodge, model=Hellcat, year=2016, price=76500.0, color=orange
Your 3 cars are worth $515,060.00
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 1 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education