Program9.java Two files are required, a data class named Car and an executable class named CarsTest. 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 CarsTest code a main method and another value-returning method named carsValue In main: create at least six Car instances, ensuring that at least three have model years less than 2018. create at least four Car instances using the parameterized constructor. create at least two more Car instances with the no-arg constructor use the Car class setter methods to assign values to all data members of these two cars. use the "array initializer" syntax to make an array to hold all Car objects. call the method named carsValue with the array as its sole argument. print the value returned by carsValue and the value in the unitsSold data member. In carsValue use a foreach loop to process the array passed into the method as follows: reduce the price of all vehicles with model years less than 2018 by 25%. 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.
Program9.java Two files are required, a data class named Car and an executable class named CarsTest. 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 CarsTest code a main method and another value-returning method named carsValue In main: create at least six Car instances, ensuring that at least three have model years less than 2018. create at least four Car instances using the parameterized constructor. create at least two more Car instances with the no-arg constructor use the Car class setter methods to assign values to all data members of these two cars. use the "array initializer" syntax to make an array to hold all Car objects. call the method named carsValue with the array as its sole argument. print the value returned by carsValue and the value in the unitsSold data member. In carsValue use a foreach loop to process the array passed into the method as follows: reduce the price of all vehicles with model years less than 2018 by 25%. 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.
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
Program9.java
Two files are required, a data class named Car and an executable class named CarsTest.
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 CarsTest
- code a main method and another value-returning method named carsValue
- In main:
- create at least six Car instances, ensuring that at least three have model years less than 2018.
- create at least four Car instances using the parameterized constructor.
- create at least two more Car instances with the no-arg constructor
- use the Car class setter methods to assign values to all data members of these two cars.
- use the "array initializer" syntax to make an array to hold all Car objects.
- call the method named carsValue with the array as its sole argument.
- print the value returned by carsValue and the value in the unitsSold data member.
- In carsValue
- use a foreach loop to process the array passed into the method as follows:
- reduce the price of all vehicles with model years less than 2018 by 25%.
- 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.
Recheck the requirements before you submit!
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 5 steps with 3 images
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY