Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a C++ program to manage a credit card company with at least one ADT (Accou

ID: 3910010 • Letter: W

Question

Write a C++ program to manage a credit card company with at least one ADT

(Account) with the following members:

card number, customer name, credit limit, and balance.

• The customer can pay the total amount of his/her balance or part of it.

• The customer can make a purchase using the credit card.

• The user can create, modify, and delete accounts.

• All new accounts are created with $300 credit limit.

• Customers’ data is stored in a binary file.

Assignment: Credit Card Company Program Cont’d

• The program’s main menu has the following options:

1. Create a new account

2. Pay balance

3. Make a purchase

4. Check balance

5. Edit an account

6. Close an account

7. View all accounts

8. Exit

Assignment: Credit Card Company Program Cont’d

• Two types of output:

1. Text output printed on the screen.

Messages like “account closed!”.

(Part A of your homework).

2. LED indicators’ lights on a breadboard connected to Raspberry Pi GPIO port.

(Part B of your graded work in the lab)

Assignment: Credit Card Company Program Cont’d

• Text Output (Part A of your homework):

• Create a new account: Print “Account created” on success or “Creation Failed” on

failure (duplicate credit card number)

• Pay balance: Print “Fully paid off” on full payment or “partially paid off” if partial

payment is made.

• Make a purchase: Print “Purchase made” on success or “Purchase Failed” on

failure (purchase amount exceeds the remaining credit limit)

• Check balance: Print “No balance to pay” if balance is 0, “Card maxed out” if

balance = credit limit (credit limit is reached), “Your balance is XXX” otherwise.

• Edit an account: Print “Account modified” on success or “Modification Failed” on

failure (duplicate credit card number)

• Close an account: Print “Account closed” on success or “Closing Failed” on failure

(cannot close an account if balance is not paid off first)

Explanation / Answer

Source code:-
============
#include<iostream>
#include<string.h>
#include<stdlib.h>
using namespace std;
struct Bank_Account
{
    int account_no;
    char first_name[80];
    char LastName[80];
    char User_id[80];
    char Password[80];
    int balance;
};
class Account{
    public:
        string username,Password;
        double balance;
        Account(string username,string Password)
        {
            this->username=username;
            this->Password=Password;
            balance=0;
        }
    public:
    int getUserName(char uname[],char pass[],struct Bank_Account array[],int size)
    {
        int index;
        for(index=0;index<size;index++)
        {
            if (!(strcmp(array[index].User_id,uname)))
            {
                return 1;
            }   
        }
           return -1;
    }
    void currentBalance(struct Bank_Account array[], int size, int Account_number)
    {
        int index;
        index=Search_Account(array, size, Account_number);
        if(index==-1)
        {
              cout<<" **** Data Not Found:****"<<endl;
        }   
        else
        {
            balance=array[index].balance;
            cout<<" The Available Balance is: "<<balance<<endl;
        }
    }
    void Read_Data(struct Bank_Account list[], int size)
    {
        int i;
        for(i=0;i<size;i++)
        {
            cout<<" ------------------------------"<<endl;
            cout<<" Please Record Person "<<i+1<<" Details"<<endl;
            list[i].account_no=i+1;
            fflush(stdin);
            cout<<"Enter the FirstName: "<<endl;
            gets(list[i].first_name);
            cout<<"Enter the LastName: "<<endl;
            gets(list[i].LastName);
            cout<<" Please Create Userid:"<<endl;
            gets(list[i].User_id);
            cout<<" Please Create your Password"<<endl;
            gets(list[i].Password);
            list[i].balance = 100;
            cout<<" Your Account Number is: "<<list[i].account_no<<endl;
        }
    }
    void Display_Record(struct Bank_Account array[], int size)
    {
        int index;
        cout<<" A/c Number: Name: Balance:"<<endl;
        for(index=0;index<size;index++)
        {
               cout<<array[index].account_no<<" "<<array[index].first_name<<" "<<array[index].balance<<endl;
        }
    }

    int Search_Account(struct Bank_Account array[], int size, int Account_number)
    {
        int index;
        for(index=0;index<size;index++)
        {
            if (array[index].account_no == Account_number)
            {
                return index;
            }   
        }
           return - 1;
    }
    void Deposit(struct Bank_Account array[], int size, int Account_number, int Amount)
    {
        int index;
        index=Search_Account(array, size, Account_number);
        if(index==-1)
        {
              cout<<" **** Data Not Found:****"<<endl;
        }   
        else
        {
            array[index].balance=array[index].balance+Amount;
        }
    }
    void withdrawal(struct Bank_Account array[], int size, int Account_number, int Amount)
    {
        int index;
        index=Search_Account(array, size, Account_number);
        if(index==-1)
        {
               cout<<" **** Data Not Found:****"<<endl;
        }   
        else
        {
            if (array[index].balance<Amount)
            {
                cout<<"Insufficient balance "<<endl;
            }
            else
            {
                array[index].balance=array[index].balance-Amount;
            }
        }
    }
       
};
using namespace std;
int main()
{
    struct Bank_Account array[10];
    Account obj("venky","Venky@547");
    int size, option, account_no, amount;
    int retval,position;
    char Username[100],Password[100];
    cout<<" ----------------------------------"<<endl;
    cout<<" **** Welcome to Banking System*****"<<endl;
    cout<<" Please Read Number of customer records you want to Store:"<<endl;
    cin>>size;
    obj.Read_Data(array, size);
    do{
        cout<<" Please Login to your account with Password Credentials"<<endl;
        cout<<" Please Enter UserName"<<endl;
        cin>>Username;
        cout<<" Please Enter the Password"<<endl;
        cin>>Password;
        retval=obj.getUserName(Username,Password,array,size);
        if(retval==-1)
        {
                cout<<" !invalid username or password please try again "<<endl;
        }
    }while(retval==-1);
    while(1)
    {
        cout<<" ----------------------------------"<<endl;
        cout<<" ****** MENU ********"<<endl;
        cout<<" 1.To view Their Account Balance"<<endl;
        cout<<" 2.To deposit amount"<<endl;
        cout<<" 3.To withdraw amount"<<endl;
        cout<<" 4.Display Account Holder Details"<<endl;
        cout<<" 5.Exit/Logout:"<<endl;
        cout<<" Select Any Option "<<endl;
        cin>>option;
        switch (option)
        {
            case 1:
                cout<<" Please Enter your account number:"<<endl;
                cin>>account_no;
                obj.currentBalance(array, size,account_no);
                break;
            case 2:
                cout<<" Please Enter your account number:"<<endl;
                cin>>account_no;
                cout<<" Please Enter amount to deposit:"<<endl;
                cin>>amount;
                obj.Deposit(array, size, account_no, amount);
                break;
            case 3:
                cout<<" Please Enter your account number:"<<endl;
                cin>>account_no;
                cout<<" Please Enter amount to withdraw:"<<endl;
                cin>>amount;
                obj.withdrawal(array, size, account_no, amount);
                break;
            case 4:
               cout<<" Please Enter account number to search"<<endl;
                cin>>account_no;
                retval = obj.Search_Account(array, size, account_no);
                position=retval;
                if (retval == - 1)
                {
                   cout<<" No Record Found"<<endl;
                }
                else
                {
                   cout<<" A/c Number: Name: Balance: "<<endl;
                   cout<<array[position].account_no<<" "<<array[position].first_name<<" "<<array[position].balance<<endl;
                }
                break;
            case 5:
                exit(0);
        }
    }

    return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote