Question

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

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)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

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<<"\n**** Data Not Found:****"<<endl;
        }   
        else
        {
            balance=array[index].balance;
            cout<<"\nThe Available Balance is: "<<balance<<endl;
        }
    }
    void Read_Data(struct Bank_Account list[], int size)
    {
        int i;
        for(i=0;i<size;i++)
        {
            cout<<"\n------------------------------"<<endl;
            cout<<"\nPlease 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<<"\nPlease Create Userid:"<<endl;
            gets(list[i].User_id);
            cout<<"\nPlease Create your Password"<<endl;
            gets(list[i].Password);
            list[i].balance = 100;
            cout<<"\nYour Account Number is: "<<list[i].account_no<<endl;
        }
    }
    void Display_Record(struct Bank_Account array[], int size)
    {
        int index;
        cout<<"\nA/c Number:\tName:\tBalance:"<<endl;
        for(index=0;index<size;index++)
        {
               cout<<array[index].account_no<<"\t"<<array[index].first_name<<"\t"<<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<<"\n**** 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<<"\n**** Data Not Found:****"<<endl;
        }   
        else
        {
            if (array[index].balance<Amount)
            {
                cout<<"Insufficient balance\n"<<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<<"\n----------------------------------"<<endl;
    cout<<"\n**** Welcome to Banking System*****"<<endl;
    cout<<"\n Please Read Number of customer records you want to Store:"<<endl;
    cin>>size;
    obj.Read_Data(array, size);
    do{
        cout<<"\nPlease Login to your account with Password Credentials"<<endl;
        cout<<"\nPlease Enter UserName"<<endl;
        cin>>Username;
        cout<<"\nPlease Enter the Password"<<endl;
        cin>>Password;
        retval=obj.getUserName(Username,Password,array,size);
        if(retval==-1)
        {
                cout<<"\n!invalid username or password please try again\n"<<endl;
        }
    }while(retval==-1);
    while(1)
    {
        cout<<"\n----------------------------------"<<endl;
        cout<<"\n****** MENU ********"<<endl;
        cout<<"\n1.To view Their Account Balance"<<endl;
        cout<<"\n2.To deposit amount"<<endl;
        cout<<"\n3.To withdraw amount"<<endl;
        cout<<"\n4.Display Account Holder Details"<<endl;
        cout<<"\n5.Exit/Logout:"<<endl;
        cout<<"\nSelect Any Option "<<endl;
        cin>>option;
        switch (option)
        {
            case 1:
                cout<<"\nPlease Enter your account number:"<<endl;
                cin>>account_no;
                obj.currentBalance(array, size,account_no);
                break;
            case 2:
                cout<<"\nPlease Enter your account number:"<<endl;
                cin>>account_no;
                cout<<"\nPlease Enter amount to deposit:"<<endl;
                cin>>amount;
                obj.Deposit(array, size, account_no, amount);
                break;
            case 3:
                cout<<"\nPlease Enter your account number:"<<endl;
                cin>>account_no;
                cout<<"\nPlease Enter amount to withdraw:"<<endl;
                cin>>amount;
                obj.withdrawal(array, size, account_no, amount);
                break;
            case 4:
               cout<<"\nPlease Enter account number to search"<<endl;
                cin>>account_no;
                retval = obj.Search_Account(array, size, account_no);
                position=retval;
                if (retval == - 1)
                {
                   cout<<"\nNo Record Found"<<endl;
                }
                else
                {
                   cout<<"\nA/c Number:\tName:\tBalance:\n"<<endl;
                   cout<<array[position].account_no<<"\t"<<array[position].first_name<<"\t"<<array[position].balance<<endl;
                }
                break;
            case 5:
                exit(0);
        }
    }

    return 0;
}

Add a comment
Know the answer?
Add Answer to:
Write a C++ program to manage a credit card company with at least one ADT (Account)...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Design and implement an ADT in JAVA that represents a credit card. it should include the...

    Design and implement an ADT in JAVA that represents a credit card. it should include the customer name, the account number, credit limit, the reward points and the account balance. The initialization operation should set the data to client-supplied values. The credit limit will be initializes to $5000 and reward points to 0. Next, write a method to validate the card number using the Luhn Algorithm and implement it as a part of initialization process. If the number is invalid,...

  • 9. Credit Cards: a. If you have a balance of $1,245.00 on your credit card, how...

    9. Credit Cards: a. If you have a balance of $1,245.00 on your credit card, how long will it take you to pay off the balance if you make $50.00/month payments until it is paid off? The APR is 19%. b. What will be your monthly payment on a credit card with a balance of $2,456.80, if you desire to pay it off in 2 years, at an APR of 23.99%? 10. A furniture company allows customers to purchase household...

  • Service Company Insight American Express That Letter from credit card account? American Express decided to offer...

    Service Company Insight American Express That Letter from credit card account? American Express decided to offer AmEx Might Not some of its customers $300 if they would give back their Be a Bill credit card. You could receive the $300 even if you hadn't No doubt every one of paid off your balance yet, as long as you agreed to give up you has received an invis your credit card. tation from a credit card Source Aparajita Saha-Bubna and Lauren...

  • If the credit card has an annual interest rate of 13.6% and only the minimum monthly payment of $35 is made, how many months will it take to pay off the credit card?

    Part 2: Credit Cards Another type of personal loan is a credit card. A financial institution allows you to charge a purchase to your account, and you are required to pay the financial institution at a later time. As with other loans, credit cards charge interest. Interest rates can range from 3% - 22%. When you are paying for debt on a credit card, the financial institution will require a minimum balance be paid each month. The higher the interest rate that is charged...

  • C++ Design a class bankAccount that defines a bank account as an ADT and implements the...

    C++ Design a class bankAccount that defines a bank account as an ADT and implements the basic properties of a bank account. The program will be an interactive, menu-driven program. a. Each object of the class bankAccount will hold the following information about an account: account holder’s name account number balance interest rate The data members MUST be private. Create an array of the bankAccount class that can hold up to 20 class objects. b. Include the member functions to...

  • BANKING MANAGEMENT

    Banking System is developed in C++ to replaced manual System by a computerized system. This system allows to create a new account and Allows to deposit and withdrawal amount facilities. Account Holder ABS must record the detailed information of each account holder, such as  Type of his account (see next slides for more info)  Type of Credit card (see later slides for more info)  First name, middle name, and last name  CNIC number Address Telephone number Date of...

  • On January 1, Wei company begins the accounting period with a $36,000 credit balance in Allowance for Doubtf...

    On January 1, Wei company begins the accounting period with a $36,000 credit balance in Allowance for Doubtful Accounts. a. On February 1, the company determined that $8,000 in customer accounts was uncollectible, specifically, $1,500 for Oakley Co. and $6,500 for Brookes Co. Prepare the journal entry to write off those two accounts. b. On June 5, the company unexpectedly received a $1,500 payment on a customer account, Oakley Company, that had previously been written off in part a. Prepare...

  • Write in C++ using emacs. Write a program that calculates the ending balance of several savings...

    Write in C++ using emacs. Write a program that calculates the ending balance of several savings accounts. The program reads information about different customers’ accounts from an input file, “accounts.txt”. Each row in the file contains account information for one customer. This includes: the account number, account type (premium, choice, or basic account), starting balance, total amount deposited, and total amount withdrawn. Your program should: - open the file and check for successful open, - then calculate the ending balance...

  • C++ code and also provide comments explaining everything Credit Card Debt The True Cost of Paying...

    C++ code and also provide comments explaining everything Credit Card Debt The True Cost of Paying Minimum Payment Write a C++ program to output the monthly payment schedule for a credit card debt, when each month nothing more is charged to the account but only the minimum payment is paid. The output stops when the balance is fully paid - remaining balance = 0. Input: Data input must be done in a separate function. Input the following: credit card balance,...

  • On January 1, Wei company begins the accounting period with a $41,000 credit balance in Allowance...

    On January 1, Wei company begins the accounting period with a $41,000 credit balance in Allowance for Doubtful Accounts. a. On February 1, the company determined that $9,000 in customer accounts was uncollectible; specifically, $2,000 for Oakley Co. and $7,000 for Brookes Co. Prepare the journal entry to write off those two accounts. b. On June 5, the company unexpectedly received a $2,000 payment on a customer account, Oakley Company, that had previously been written off in part a. Prepare...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT