Assignment #2
Marks : assignment + viva (5+5) Submission date: 10-11-2025
Topic Object passing & Return, Array of object
Q1: Write a Program to Print the Name, salary, Data of Joining of 10 Employee in Company.
Q2: Create a class ‘Student’ with three data members which are name, age and address. The
constructor of the class assigns default values name as “unknown”, age as ‘0’ and address as “not
available”. It has two members with the same name ‘setInfo’. First method has two parameters for
name and age and assigns the same whereas the second method takes has three parameters which
are assigned to name, age and address respectively. Print the name, age and address of 10 students.
Q:3 Write a program to print the Roll No and Average Marks of 8 Student in Three Subject. The Marks
are entered by User.
Q4: Write a program to calculate the average height of all students of the class. The Number Of
student and height in a class are entered by user.
Q5: Let’s create a bank account. Create a class named ' Bank Account ' with the following data
members.
1- Name of depositor
2- Address of depositor
3- Type of account
4- Balance in account
5- Number of transactions
Class ' Bank Account ' has a method for each of the following.
1 - Generate a unique account number for each depositor For first depositor, account number will be
BA1000, for second depositor it will be BA1001 and so on
2- Display information and balance of depositor
3 - Deposit more amount in balance of any depositor
4 - Withdraw some amount from balance deposited
5- Change address of depositor
After creating the class, do the following operations
1- Enter the information (name, address, type of account, balance) of the depositors. Number of
depositors is to be entered by user.
2- Print the information of any depositor.
3- Add some amount to the account of any depositor and then display final information of that
depositor.
Q6. Write a program to create a directory that contains the following information .
( a ) Name of a person
( b ) Address
( c ) Telephone Number ( if available with STD code )
( d ) Mobile Number ( if available )
( e ) Head of the family
( f ) Unique ID No.
The program will support the following menu based activities :
( a ) Create a database entry ( The Unique ID number must be unique for every entry , the telephone
numbers of two or more persons can be same if and only if the head of family is same )
( b ) Edit an entry ( Must be identified by only the Unique ID number )
( c ) Search by keyword ( Any keyword may not be complete ; even if the keyword matches partially with
any field , the corresponding information must be displayed ).
Q7: Write a program to create a room, the attributes of this class is roomno, roomtype, roomarea,
and ACmachine. In this class have a constructor using object as a parameter to an initialize the
instance variable. The value of the variable input from the user. Class has method name ‘displaydata’
to print data.
Q8: Write a program to create a class “car” having data member is “car-number”, method Swap () for
swapping data and display () to display the data after swapping members. Create two objects of same
class with different car-number .Swap the object member value by passing object to method.
Q9: Write a program to create a class Area having instance variable length, breath, area (input values
from user) and method area1 () and area2 (). Passing the object as a parameter to both methods and
pass the value to instance variable by method (classtype objectname) and calculate the area using
(length+breath). area2 () add the 5 in length and 8 in breath. Print the area in both methods.