0% found this document useful (0 votes)
3 views

24F-0016

The document contains C++ code for a customer data management system and a banking system. The customer management system includes classes for person and customer data, allowing input and display of customer details. The banking system features various account types (savings, current, business, premium savings) with functionalities for interest calculation, withdrawals, and loan approvals.

Uploaded by

f230003
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)
3 views

24F-0016

The document contains C++ code for a customer data management system and a banking system. The customer management system includes classes for person and customer data, allowing input and display of customer details. The banking system features various account types (savings, current, business, premium savings) with functionalities for interest calculation, withdrawals, and loan approvals.

Uploaded by

f230003
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/ 6

Question 01:

Main.cpp:
#include<iostream>
#include "header.h"
using namespace std;

int main()
{
CustomerData customer;
customer.inputCustomerData();
customer.displayCustomerData();

system("pause");
return 0;
}

Header.h:
#ifndef HEADER_H
#define HEADER_H

#include <iostream>
#include <string>

using namespace std;

class PersonData
{
protected:
string firstName;
string lastName;
string address;

public:
PersonData();
PersonData(string fName, string lName, string addr);
string getFirstName() const;
string getLastName() const;
string getAddress() const;
void setFirstName(string fName);
void setLastName(string lName);
void setAddress(string addr);
};

class CustomerData : public PersonData


{
private:
int customerNumber;
bool mailingList;

public:
CustomerData();
CustomerData(string fName, string lName, string addr, int custNum, bool mailList);
int getCustomerNumber() const;
bool getMailingList() const;
void setCustomerNumber(int custNum);
void setMailingList(bool mailList);
void inputCustomerData();
void displayCustomerData() const;
};
#endif

Implimentation.cpp:

#include "header.h"

PersonData::PersonData() : firstName(""), lastName(""), address("") {}

PersonData::PersonData(string fName, string lName, string addr)


: firstName(fName), lastName(lName), address(addr) {}

string PersonData::getFirstName() const { return firstName; }


string PersonData::getLastName() const { return lastName; }
string PersonData::getAddress() const { return address; }

void PersonData::setFirstName(string fName) { firstName = fName; }


void PersonData::setLastName(string lName) { lastName = lName; }
void PersonData::setAddress(string addr) { address = addr; }

CustomerData::CustomerData() : PersonData(), customerNumber(0), mailingList(false) {}

CustomerData::CustomerData(string fName, string lName, string addr, int custNum, bool


mailList)
: PersonData(fName, lName, addr), customerNumber(custNum), mailingList(mailList)
{}

int CustomerData::getCustomerNumber() const { return customerNumber; }


bool CustomerData::getMailingList() const { return mailingList; }

void CustomerData::setCustomerNumber(int custNum) { customerNumber = custNum; }


void CustomerData::setMailingList(bool mailList) { mailingList = mailList; }

void CustomerData::inputCustomerData()
{
cout << "Enter First Name : ";
cin >> firstName;
cout << "Enter Last Name : ";
cin >> lastName;
cin.ignore();
cout << "Enter Address : ";
getline(cin, address);
cout << "Enter Customer Number : ";
cin >> customerNumber;
cout << "Subscribe to mailing list, (1 for Yes, 0 for No): ";
cin >> mailingList;
}

void CustomerData::displayCustomerData() const


{
cout << "\nCustomer Details :\n";
cout << "Name : " << firstName << " " << lastName << endl;
cout << "Address : " << address << endl;
cout << "Customer Number : " << customerNumber << endl;
cout << "Mailing List : ";
if (mailingList)
{
cout << "Subscribed." << endl;
}
else {
cout << "Not Subscribed." << endl;
}
}

Question 02:
#include <iostream>
using namespace std;

class BankAccount
{
private:
int pinCode;
public:
int accountNumber;

BankAccount(int accNum, double bal, int pin)


{
accountNumber = accNum;
balance = bal;
pinCode = pin;
}

void showAccountDetails()
{
cout << "Account Number : " << accountNumber << endl;
cout << "Balance: $" << balance << endl;
}

protected:
double balance;
void calculateInterest()
{
cout << "Base interest calculation not applicable." << endl;
}
};

class SavingsAccount : public BankAccount


{
private:
double interestRate;
public:
SavingsAccount(int accNum, double bal, int pin, double rate)
: BankAccount(accNum, bal, pin)
{
interestRate = rate;
}

void calculateInterest()
{
balance += (balance * interestRate / 100);
cout << "Savings Interest Applied. New Balance : $" << balance << endl;
}

void withdraw(double amount)


{
if (amount > balance)
{
cout << "Insufficient amount." << endl;
}
else
{
balance -= amount;
cout << "Withdrawal Successful. Remaining Balance: $" << balance <<
endl;
}
}
};

class CurrentAccount : protected BankAccount


{
private:
double overdraftLimit;
public:
CurrentAccount(int accNum, double bal, int pin, double overdraft)
: BankAccount(accNum, bal, pin)
{
overdraftLimit = overdraft;
}

void useOverdraft(double amount)


{
if (amount > balance + overdraftLimit)
{
cout << "Overdraft denied. Limit exceeded." << endl;
}
else
{
balance -= amount;
cout << "Overdraft used. New Balance: $" << balance << endl;
}
}

void calculateInterest()
{
cout << "Current accounts do not have interest." << endl;
}
};

class BusinessAccount : private BankAccount


{
private:
double loanLimit;
public:
BusinessAccount(int accNum, double bal, int pin, double loan)
: BankAccount(accNum, bal, pin)
{
loanLimit = loan;
}
void approveLoan(double amount)
{
if (amount > loanLimit)
{
cout << "Loan denied! Exceeds limit of $" << loanLimit << endl;
}
else
{
cout << "Loan approved for $" << amount << endl;
}
}

void calculateInterest()
{
cout << "Business accounts have special interest rates." << endl;
}
};

class PremiumSavings : public SavingsAccount


{
public:
PremiumSavings(int accNum, double bal, int pin, double rate)
: SavingsAccount(accNum, bal, pin, rate) {}

void calculateInterest()
{
balance += (balance * 5.0 / 100);
cout << "Premium Savings Interest Applied. New Balance : $" << balance <<
endl;
}
};

int main()
{
cout << "Savings Account :" << endl;
SavingsAccount sa(101, 5000, 1234, 2.5);
sa.showAccountDetails();
sa.calculateInterest();
sa.withdraw(1000);

cout << "\nCurrent Account :" << endl;


CurrentAccount ca(202, 3000, 5678, 500);
ca.useOverdraft(200);
ca.useOverdraft(600);

cout << "\nBusiness Account :" << endl;


BusinessAccount ba(303, 10000, 7890, 20000);
ba.approveLoan(15000);
ba.approveLoan(25000);

cout << "\nPremium Savings Account :" << endl;


PremiumSavings ps(404, 7000, 3456, 3.0);
ps.showAccountDetails();
ps.calculateInterest();

system("pause");
return 0;
}

You might also like