0% found this document useful (0 votes)
92 views2 pages

Assignment 5

Rdg

Uploaded by

mahatonikita00
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
92 views2 pages

Assignment 5

Rdg

Uploaded by

mahatonikita00
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Assignment 5

1. Write a Java program to create a class called Shape with methods called
getPerimeter() and getArea(). Create a subclass called Circle that
overrides the getPerimeter() and getArea() methods to calculate the area
and perimeter of a circle.
2. Write a Java program to create a vehicle class hierarchy. The base class
should be Vehicle, with subclasses Truck, Car and Motorcycle. Each
subclass should have properties such as make, model, year, and fuel type.
Implement methods for calculating fuel efficiency, distance traveled, and
maximum speed.
cargoCapacity for truck
NoOfSits for car
EngineDisplacement for MotorCycle
Note: Fuel efficiency = Divide the number of kilometers by the number of litres
consumed
3. Write a Java program to create a class known as "BankAccount" with
methods called deposit() and withdraw() and members accountNumber
and balance. Create a subclass called SavingsAccount that overrides the
withdraw() method to prevent withdrawals if the account balance falls
below one hundred.

4. Write a Java program to create a class called Animal with a method


named move(). Create a subclass called Cheetah that overrides the
move() method to run.
5. Write a Java program that creates a class hierarchy for employees of a
company. The base class should be Employee, with subclasses Manager,
Developer, and Programmer. Each subclass should have properties such
as name, address, salary, and job title. Implement methods for calculating
bonuses, generating performance reports, and managing projects.

Note: Bonus = salary*%of bonus


Performance report may be Outstanding, Excellent, Satisfactory
Manager class have member: numberOfsubOrdinate and custom method:
manageProjects().
Developer class have custom methods programmingLanguage() and writeCode(),
member: programmingLanguage
Programmer class have custom method debugCode()

You might also like