Question
1- Create new java package inside the project and name it cars_pkg . (0.5m) 2- Add new class to the cars_pkg and name it Car.
1- Create new java package inside the project and name it cars_pkg. (0.5m)
2- Add new class to the cars_pkg and name it Car. (1m)
3- Add the following attributes (member variables): to the Car class
Plate_no, type and rent (type attribute can take values like small, CVS, or family). (1m)
4- Attributes should be encapsulated within the class. (2m)
5- Add a constructor to the class that initialize all variables. (1m)
6- Add calculate_rent() method to Car class. the method should take one integer parameters (day) and return Rent * day. (1m)
7- Add display method to car class that print all details on one line (2m)
8- In the main program:
a. Create an instance of the Car class. (2m)
b. Call the calculate_rent () for 5 days and display details of the car. (1m)
c. The main program should handle All Exception (0.5m)
9- Add some comments to your program. (0.5m)
10- Test your program. (0.5m)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started