Professional Documents
Culture Documents
Exercises
1. Write a class Employee having data members to store the following
information: Name, Father’s
Name, CNIC, Department, Salary and Designation. Write a method void printInfo()
that prints
all information of the employee. Also write a class to test all methods of
Employee class.
2. Write a class Box having data members to store the following information:
Width, Height and Depth
Create two objects myBox1 and myBox2 for the above class.
Print values of width, depth and height for each object.
Calculate volume for both objects.
3. Write a class Student having attributes to store the following data: Name,
Fathers’ Name,
Department, Degree, Enrolment, Seat number, and Marks of three subjects. Add
the following
annual interest rate for all account holders. The class also contains an instance
variable
savingsBalance indicating the amount the saver currently has on deposit. Provide
method
saver2, with balances of Rs. 20,000.00/- and Rs. 300,000.00/- respectively. Set
annualInterestRate
to 4%, then calculate the monthly interest and print the new balances for both
savers. Then set the
annualInterestRate to 5%, calculate the next month’s interest and print the new
balances for both
savers.