Assignment 3

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Assignment # 3

Q-1. Define a class employee. Include the following members:


Data Members:
a. Name of the employee b.
Age of the employee Member
Functions:
a. To get the name and age of the employee
b. To display the name and age of the employee.
Q-2. Define a class BankAccount to represent a bank account. Include the
following
Data Members:
1. Name of the depositor
2. Account Number
3. Type of account
4. Balance amount in the account
Member Functions:
1. To assign initial value
2. To deposit an amount
3. To withdraw an amount after checking
Q-3. Define a class employee having data members as emp_code, dept_code,
age, basic, DA, HRA and three member functions as getdata(), putdata(),
calculatesalary() to get, display all the values of data members and calculate the
total salary by adding basic, DA, HRA. Write this program for 10(ten) employees
using an array of objects.
BANKING OPERATION USING CLASS AND OBJECTS
Algorithm
Step 1: Create an object b of the class bank Account.
Step 2: Read the number of records.
Step 3: call the init member function of the class bank account through the object
created.
Step 4: Assign 500 to the balance in the records.
Step 5: Display a menu with the following options create deposit withdraw
display.
Step 6: Read the choice.
Step 7: If the choice is create then call the create member function using the
object.
Step 8: prompt and read the users name, account number and account type for

all the n records.


Step 9: If the choice is deposit call the deposit member function using the
function.
Step 10: Read the account number.
Step 11: Check whether this account number is already exiting in the list. If true
Step 12: Read the amount to be deposited.
Step 13: Update the balance by adding the amount deposited to the balance.
Step 14: Display the balance.
Step 15: If the choice is withdraw, call the withdraw member function.
Step 16: Using object Read the account number.
Step 17: Check the account number existing in the list then.
Step 18: Read the amount to be withdrawn.
Step 19: Retrieve the amount from balance.
Step 20: If the balance is less than 500 then
Step 21: Calculate balance + withdraw amount-500.
Step 22: Assign 500 to the balance.
Step 23: Display the withdrawn amount.
Step 24: If the choice is display, invoke the display member function using the
Object.
Step 25: Read the account number.
Step 26: If this account number is existing in the list then.
Step 27: Display the details such as name, account number, account type and
balance in the given account number.

You might also like