CS112L Lab9
CS112L Lab9
Tasks1:
Define a base class "Account" with attributes like "accountNumber" and "balance", along with
methods for depositing and withdrawing funds. Create a derived class "SavingsAccount" inheriting
from "Account", adding functionality for calculating interest and displaying balance. Implement a
scenario where a user opens a savings account, deposits funds, earns interest, and withdraws money.
Tasks2:
Define a base class "Vehicle" with methods for starting and stopping the engine, along with attributes
like "make" and "model". Create a derived class "Car" inheriting from "Vehicle" and adding features
like automatic transmission. Further, derive a class "ElectricCar" from "Car" and add functionality
for charging the battery. Simulate a scenario where an electric car is used, starting its engine, driving,
and then charging the battery.
Tasks3:
Develop a base class "Person" with attributes like "name" and "age", along with methods for
displaying information. Create two derived classes: "Student" and "Teacher", both inheriting from
"Person" and adding features specific to students and teachers respectively. Illustrate a scenario
where a school registers both students and teachers, displaying their information.