CS201P Assignment 2 Correct Solution Spring 2025
CS201P Assignment 2 Correct Solution Spring 2025
VUAnswer.pk
Note: Remember that if you have not used your Name and student ID in the program, your
marks will be deducted.
Problem Statement:
WhatsApp: +923162965677
MORE SOLUTIONS, HANDOUTS AND PAST PAPERS FREELY VISIT
VUAnswer.pk
Design a simple Bank Management System that helps simulate some basic banking operations for
an account holder. You are required to use classes, objects, functions, and function calling as core
components in your solution.
Requirements:
accountHolderName
accountNumber
balance
WhatsApp: +923162965677
MORE SOLUTIONS, HANDOUTS AND PAST PAPERS FREELY VISIT
VUAnswer.pk
Create an object of the class using the parameterized constructor with
hardcoded data.
Perform at least one deposit and one withdrawal operation for each account
using appropriate function calls.
Display account summary after transaction.
SOLUTION
CODE
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
class BankAccount {
private:
string accountHolderName;
string accountNumber;
double balance;
public:
// Parameterized constructor
BankAccount(string name, string accNumber, double initialBalance) {
accountHolderName = name;
WhatsApp: +923162965677
MORE SOLUTIONS, HANDOUTS AND PAST PAPERS FREELY VISIT
VUAnswer.pk
accountNumber = accNumber;
balance = initialBalance;
}
WhatsApp: +923162965677
MORE SOLUTIONS, HANDOUTS AND PAST PAPERS FREELY VISIT
VUAnswer.pk
cout << "Withdrawing amount: " << withdrawAmount << endl;
cout << "Balance after withdrawal: " << balance << endl;
}
}
int main() {
// Student information (replace with your details)
string studentName = "Sarim"; // Replace with your actual name
string vuid = "BC123456789"; // Replace with your actual VUID
WhatsApp: +923162965677
MORE SOLUTIONS, HANDOUTS AND PAST PAPERS FREELY VISIT
VUAnswer.pk
BankAccount account(studentName, vuid, initialBalance);
// Perform transactions
cout << "\nPerforming transactions..." << endl;
account.deposit(); // Deposit last 4 digits of VUID
account.withdraw(); // Withdraw first 4 digits of VUID
return 0;
}
OUTPUT SCREENSHOT
WhatsApp: +923162965677
MORE SOLUTIONS, HANDOUTS AND PAST PAPERS FREELY VISIT
VUAnswer.pk
WhatsApp: +923162965677
MORE SOLUTIONS, HANDOUTS AND PAST PAPERS FREELY VISIT
VUAnswer.pk
REGARD - SARIM
WHATSAPP +923162965677
PLEASE NOTE:
Don't copy-paste the same answer.
Make sure you can make some changes to your solution file before
submitting copy paste solution will be marked zero.
If you found any mistake then correct yourself and inform me.
Before submitting an assignment must check your assignment requirement
file.
If you need some help or question about file and solutions feel free to ask.
VUAnswer.pk
WhatsApp: +923162965677