[go: up one dir, main page]

0% found this document useful (0 votes)
64 views8 pages

CS201P Assignment 2 Correct Solution Spring 2025

The document outlines the requirements for CS201P Assignment 2, which involves designing a simple Bank Management System using C++. Students must create a BankAccount class with specific data members and functions, and submit their solution as a .cpp file by June 20, 2025. It also includes instructions for contacting for paid solutions and emphasizes the importance of originality in submissions.

Uploaded by

qasimdhair10
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views8 pages

CS201P Assignment 2 Correct Solution Spring 2025

The document outlines the requirements for CS201P Assignment 2, which involves designing a simple Bank Management System using C++. Students must create a BankAccount class with specific data members and functions, and submit their solution as a .cpp file by June 20, 2025. It also includes instructions for contacting for paid solutions and emphasizes the importance of originality in submissions.

Uploaded by

qasimdhair10
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

MORE SOLUTIONS, HANDOUTS AND PAST PAPERS FREELY VISIT

VUAnswer.pk

CS201P ASSIGNMENT 2 SOLUTION SPRING 2025

Due Date: 20-June-2025


Total Marks: 20

DO NOT COPY PASTE THE SAME

FOR PAID SOLUTION WITH YOUR VU ID, NAME


CONTACT US WHATSAPP 03162965677

Assignment Submission Instruction:


You must submit only a .cpp file on the assignments interface of CS201P from your LMS
account. Assignments submitted in any other format(image, pdf, doc, docx, etc) will be scaled
with zero marks.

Note: Remember that if you have not used your Name and student ID in the program, your
marks will be deducted.

Problem Statement:

FOR PAID ASSIGNMENTS CORRECT SOLUTION CONTACT

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:

1. Create a class named BankAccount with the following data members:

 accountHolderName

 accountNumber

 balance

2. The class must have the following functions:

 Create a parameterized constructor to assign values to the account holder's


name, account number (use your complete VUID), and initial balance.
You will create only one account using this constructor, and the account
number must be your complete VUID (e.g., BC123456789). A member
function deposit() that adds the given amount to the balance. You can use the
numeric part of your VUID manually and use an initial balance of 10,000
hardcoded. When calling the deposit() function, the deposit amount must be
the last four digits of your VUID (e.g., if VUID is BC123456789, the
deposit amount should be 6789).
 A member function withdraw() that subtracts the given amount from the
balance if sufficient funds are available; otherwise, display a message
"Insufficient Balance".When calling the withdraw() function, the withdrawal
amount must be the first four digits of your VUID (e.g., from
BC123456789, the withdrawal amount would be 1234).
 A member function displayDetails() that shows all account information along
with the current balance.

3. In your main() function:

FOR PAID ASSIGNMENTS CORRECT SOLUTION CONTACT

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;

FOR PAID ASSIGNMENTS CORRECT SOLUTION CONTACT

WhatsApp: +923162965677
MORE SOLUTIONS, HANDOUTS AND PAST PAPERS FREELY VISIT

VUAnswer.pk
accountNumber = accNumber;
balance = initialBalance;
}

// Deposit function (adds last 4 digits of VUID to balance)


void deposit() {
string depositStr = accountNumber.substr(accountNumber.length() - 4); // Last 4 digits of
VUID
double depositAmount = atoi(depositStr.c_str()); // Convert to integer
balance += depositAmount;
cout << "Depositing amount: " << depositAmount << endl;
cout << "Balance after deposit: " << balance << endl;
}

// Withdraw function (subtracts first 4 digits of VUID from balance)


void withdraw() {
string withdrawStr = accountNumber.substr(2, 4); // First 4 digits after 'BC'
double withdrawAmount = atoi(withdrawStr.c_str()); // Convert to integer

if (withdrawAmount > balance) {


cout << "Insufficient Balance" << endl;
} else {
balance -= withdrawAmount;

FOR PAID ASSIGNMENTS CORRECT SOLUTION CONTACT

WhatsApp: +923162965677
MORE SOLUTIONS, HANDOUTS AND PAST PAPERS FREELY VISIT

VUAnswer.pk
cout << "Withdrawing amount: " << withdrawAmount << endl;
cout << "Balance after withdrawal: " << balance << endl;
}
}

// Display account details


void displayDetails() {
cout << "\n----- Account Summary -----" << endl;
cout << "Account Holder: " << accountHolderName << endl;
cout << "Account Number: " << accountNumber << endl;
cout << "Current Balance: " << balance << endl;
cout << "--------------------------" << 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

double initialBalance = 10000.0; // Hardcoded initial balance

// Create bank account

FOR PAID ASSIGNMENTS CORRECT SOLUTION CONTACT

WhatsApp: +923162965677
MORE SOLUTIONS, HANDOUTS AND PAST PAPERS FREELY VISIT

VUAnswer.pk
BankAccount account(studentName, vuid, initialBalance);

// Display initial account details


cout << "Account Created Successfully!" << endl;
cout << "Account Holder Name: " << studentName << endl;
cout << "Account Number (VUID): " << vuid << endl;
cout << "Initial Balance: " << initialBalance << endl;

// Perform transactions
cout << "\nPerforming transactions..." << endl;
account.deposit(); // Deposit last 4 digits of VUID
account.withdraw(); // Withdraw first 4 digits of VUID

// Display final details


account.displayDetails();

return 0;
}

OUTPUT SCREENSHOT

FOR PAID ASSIGNMENTS CORRECT SOLUTION CONTACT

WhatsApp: +923162965677
MORE SOLUTIONS, HANDOUTS AND PAST PAPERS FREELY VISIT

VUAnswer.pk

FOR PAID ASSIGNMENTS CORRECT SOLUTION CONTACT

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.

FOR FREE ASSIGNMENTS SOLUTIONS VISIT

VUAnswer.pk

FOR PAID ASSIGNMENTS CORRECT SOLUTION CONTACT

WhatsApp: +923162965677

You might also like