Name: Anees Abbasi Submitted to: Dr Saima Jabeen
Department: Ai-22-Blue
Assignment No: 3
Object Oriented Programing
Question no 1:
Write a program to add, subtract, multiply and divide any two objects of a class using binary C++
Operator Overloading. Also, the same program should make use of unary decrement operator for the
array elements of a class (both subscript “[]” and “--” operators need to be overloaded).
Code:
#include <iostream>
using namespace std;
class MyClass
private:
int value;
public:
MyClass(int val = 0)
value = val;
MyClass operator+(const MyClass& other)
return MyClass(value + other.value);
MyClass operator-(const MyClass& other)
return MyClass(value - other.value);
}
Name: Anees Abbasi Submitted to: Dr Saima Jabeen
Department: Ai-22-Blue
MyClass operator*(const MyClass& other)
return MyClass(value * other.value);
MyClass operator/(const MyClass& other)
if (other.value == 0) {
cout << "Error: Division by zero!" << endl;
return MyClass();
return MyClass(value / other.value);
MyClass& operator--()
value--;
return *this;
MyClass operator--(int)
MyClass temp = *this;
--(*this);
return temp;
int getValue() const {
return value;
};
Name: Anees Abbasi Submitted to: Dr Saima Jabeen
Department: Ai-22-Blue
int main() {
MyClass a(10);
MyClass b(5);
MyClass sum = a + b;
MyClass difference = a - b;
MyClass product = a * b;
MyClass quotient = a / b;
cout << "The Sum is= " << sum.getValue() << endl;
cout << "The Difference is = " << difference.getValue() << endl;
cout << "The Product is = " << product.getValue() << endl;
cout << "The Quotient is = " << quotient.getValue() << endl;
MyClass arr[3] = { MyClass(5), MyClass(8), MyClass(3) };
cout << "Array elements before decrement: ";
for (int i = 0; i < 3; i++) {
cout << arr[i].getValue() << " ";
cout << endl;
--arr[0];
arr[1]--;
cout << "Array elements after decrement: ";
for (int i = 0; i < 3; i++) {
cout << arr[i].getValue() << " ";
cout << endl;
Name: Anees Abbasi Submitted to: Dr Saima Jabeen
Department: Ai-22-Blue
return 0;
Output:
Question 2:
Project Requirements:
Title:
“Bank/Finance Management System”
Your Team Name:
Oop Coders
Name of Team lead:
Talha Mehmood Kiyani.
Team members:
Anees abbasi.
Abdul Rafay.
Talha Mehmood Kiyani.
Muhammad Ali.
Problem Specification/Inputs:
The Finance in Bank Management System project aims to provide a computerized solution for
managing bank accounts and other finances. The system allows users to perform various
operations such as creating new bank accounts, depositing money, withdrawing money,
checking balance, updating account details, and closing accounts.
The system maintains information about each bank account, including the account number,
account holder's name, type of account (current or savings), and the total amount of money
deposited in the account.
Name: Anees Abbasi Submitted to: Dr Saima Jabeen
Department: Ai-22-Blue
The main menu of the system offers different options for users to choose from. They can create
a new bank account by providing necessary details such as the account number, account
holder's name, type of account, and initial deposit. The system then creates the account and
assigns a unique account number to it.
Users can deposit or withdraw money from their accounts by entering the account number and
the desired amount. The system performs the requested transaction and updates the account
balance accordingly. It also ensures that sufficient balance is available for withdrawal and
provides an error message if the balance is insufficient.
The system allows users to check the balance of a specific account by entering the account
number. It displays the account details along with the current balance.
Users can also view a list of all bank account holders, showing their account numbers, names,
types of accounts, and balances. This feature provides an overview of all the accounts managed
by the system.
Account holders have the option to update their account details, including their names, types
of accounts, and balances. The system prompts users to enter the account number of the
account they wish to update and allows them to modify the desired fields.
Finally, the system allows users to close an account by providing the account number. It
removes the account from the system's records and updates the overall account list.
The Bank Management System project provides a user-friendly interface to facilitate banking
operations efficiently.
Output:
Interface:
Name: Anees Abbasi Submitted to: Dr Saima Jabeen
Department: Ai-22-Blue
Entering data in account:
Bank account Holder List:
Deleting Record:
Concepts used:
Class.
Functions.
File Management System.
Loops.
Conditions.