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

Using C++, complete the following credit card simulator. Note that this project

ID: 3860443 • Letter: U

Question

Using C++, complete the following credit card simulator. Note that this project has already been started, the file is located below the assignment requirements. Please make sure the guidelines below are followed and that the program runs similarly to the sample run as well.

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Credit Card Simulator (OOP Principles)   

In this assignment you are to create a program to simulate the operations of a credit card (as explained below); the program should be constructed using classes. Account operations include opening the account with an established limit, posting charges and payments, requesting a limit increase, and displaying account history. Data is stored in text files by account number so that you may run the program multiple times with the same account.

A sample/session might be (items in bold are user inputs):

Welcome to the Credit Card simulator!

Existing account or new (E/N): N

Your account number will be: 999999999

Your Credit Limit: $1000.00

Account: 99999999

Outstanding Balance: 0.00

Credit Limit: 1000

Available Credit: 1000

Transaction Options:

0.Quit

1.New Charge

2.Payment

3.Credit Increase Request

4.Card History

Choice: 1

Charge Amount: 100.00

Charge Description: Gas

Account: 99999999

Outstanding Balance: 100.00

Credit Limit: 1000.00

Available Credit: 900.00

Transaction Options:

0.Quit

1.New Charge

2.Payment

3.Credit Increase Request

4.Card History

Choice: 2

Payment Amount: 25

Account: 99999999

Outstanding Balance: 75.00

Credit Limit: 1000

Available Credit: 925.00

Transaction Options:

0.Quit

1.New Charge

2.Payment

3.Credit Increase Request

4.Card History

Choice: 3

Requested Increase: 250

Sorry, but your credit increase cannot be granted at this time.

Account: 99999999

Outstanding Balance: 75.00

Credit Limit: 1000

Available Credit: 925.00

Transaction Options:

0.Quit

1.New Charge

2.Payment

3.Credit Increase Request

4.Card History

Choice: 4

Transaction Log History:

            Account 99999999 created, 8/1/2008 10:00:00am

            Charge: 100, Gas, 8/1/2008 10:05:00am

            Payment: 25, 8/5/2008 4:00:00pm

            Limit Increase: 250, declined, 8/6/2008 8:00:00

Account: 99999999

Outstanding Balance: 75.47

Credit Limit: 1000

Available Credit: 924.53

Transaction Options:

0.Quit

1.New Charge

2.Payment

3.Credit Increase Request

4.Card History

Choice: 0

Thanks for using the credit card simulator!

The CREDIT CARD class should handle the normal activities related to a credit card: a) creating the account, b) making charges and payments, and c) updating the credit balance and credit limits. In addition, the Credit Card class will keep account status and transaction histories in text files.

Develop the Credit Card class according to the following guidelines:

1)The class should either create a new account or ‘load’ an old account if a valid account number is given. This would involve 2 constructors: one that takes no account number (and generates a new account) or one that accepts an account number and reads in the current values for the account. In the case of a new account, the Credit Card number should be a randomly generated value while the starting credit limit will be $1000.   In the case of an existing account, you must verify that the account actually exists (i.e., there is already a non-empty account status file). The account status (only) data should be stored in a text file named as follows: “CC” + Account Number + “.txt”.

2) Methods for processing transactions must be included. These increase and decrease the credit card balance along with the remaining credit. Make sure that the operator cannot exceed his/her credit limit with any given charge amount. Each transaction should be stored in a credit card log file, with name as follows: “CCL” + account number “+ “.txt”

3)Allow for a request for a credit increase; increases are granted in $100 increments. Use a random number generator to determine whether a credit increase request is granted or denied.

4)The display of the transaction log is to be done in the ‘view’ program (the program with main()) – there should not be any screen output done by the Credit Card Class. Each transaction log entry is time-stamped when posted to the file (as seen from the sample run).

A list of likely class properties for the Credit Card Class:

            - 2 Constructors (with and without Account number);

- account number (returns current account number);

- credit limit (returns current limit);

- credit increase (returns code indicating success/failure of increase request);

- available credit (return value);

- balance (return value);

- transaction (processes transactions and returns error status codes);

- history log (returns an appropriate structure containing account history)

Other class members may be created as you see fit.

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Here is the starting file to work with. BE SURE YOU USE THIS FILE AS IT ALREADY ESTABLISHED SOME OF THE WORK ABOVE. Thank you.

https://1drv.ms/u/s!AjLswKvo9tl3hCmqjaypoEJNjd2o

Explanation / Answer

CCrd.h

#include <string>

using namespace std;

class CCrd

{

public:

CCrd();

CCrd(int bc);

double getCredLimit();

double getBalDue();

int getAccNum();

double credAvailable();

int incre_Credit();

void trans1();

int cdInc();

bool addingChrg(double chrgAmt, const std::string& desc);

~CCrd();

private:

int accNo;

bool err;

string mssg;

double lim;

double dueAmt;

void wtStats();

void logFl(string qu);

string credName, credlastName;

double bala = lim;

double payscale;

double chrg;

};

Credit.cpp

#include "stdafx.h"

#include "CCrd.h"

#include <iostream>

#include <fstream>

#include <ctime>

#include <sstream>

using namespace std;

CCrd::CCrd()

{

string first;

ifstream ifs;

ostringstream oss;

srand((unsigned)time(0));

accNo = (rand() % 100000) + 1;

oss << accNo << flush;

first = "CC" + oss.str() + ".txt";

ifs.open(first.c_str());

while (ifs.is_open())

{

ifs.close();

accNo = (rand() % 100000) + 1;

oss << accNo << flush;

first = "CC" + oss.str() + ".txt";

ifs.open(first.c_str());

}

ifs.close();

lim = 1000;

dueAmt = 0;

credName = first;

credlastName = "CCL" + oss.str() + ".txt";

wtStats();

logFl("Account " + oss.str() + " opened. ");

}

CCrd::CCrd(int bc)

{

string first;

ifstream ifs;

ostringstream oss;

err = false;

oss << bc << flush;

first = "CC" + oss.str() + ".txt";

ifs.open(first.c_str());

if (ifs.is_open())

{

accNo = bc;

ifs >> lim;

ifs >> dueAmt;

ifs.close();

credName = first;

credlastName = "CCL" + oss.str() + ".txt";

logFl("Account " + oss.str() + " reopened.");

}

else

{

accNo = 0;

lim = 0;

dueAmt = 0;

err = true;

mssg = "Account " + oss.str() + " could not be opened.";

}

}

int CCrd::getAccNum()

{

return accNo;

}

double CCrd::getCredLimit()

{

return lim;

}

double CCrd::getBalDue()

{

return dueAmt;

}

double CCrd::credAvailable()

{

return bala;

}

void CCrd::trans1()

{

bala = bala - chrg + payscale;

dueAmt = dueAmt + chrg - payscale;

}

void CCrd::wtStats()

{

err = false;

mssg = "";

ofstream fout;

fout.open(credName.c_str());

if (fout.is_open())

{

fout << lim << endl;

fout << dueAmt << endl;

fout.close();

}

else

{

err = true;

mssg = "Unable to write status file.";

}

}

void CCrd::logFl(string qu)

{

err = false;

mssg = "";

time_t rawtime;

time(&rawtime);

ofstream fout;

fout.open(credlastName.c_str(), ios_base::app);

if (fout.is_open())

{

fout << qu << " on " << ctime(&rawtime);

fout.close();

}

else

{

err = true;

mssg = "Unable to write log entry " + qu;

}

}

CCrd::~CCrd()

{

}

CreditDisplay.cpp

#include "stdafx.h"

#include "CCrd.h"

#include <iostream>

#include <ctime>

using namespace std;

using namespace System;

int main()

{

srand((unsigned)time(nullptr));

CCrd *cc;

char ch;

int acct_no;

int answered;

double chrg = 0;

string charge_desc;

double payscale = 0;

int incr;

cout << "New or existing account? (N/E): ";

cin >> ch;

ch = toupper(ch);

if (ch == 'N')

{

cc = new CCrd();

if (cc->getAccNum() == 0)

{

cout << "Account couldn't be created.";

return(1);

}

cout << "Credit Account " << cc->getAccNum() << " was opened. " << endl;

}

else

{

cout << "Please enter Account Number: ";

cin >> acct_no;

cc = new CCrd(acct_no);

if (cc->getAccNum() == 0)

{

cout << "Account doesn't exist.";

return(2);

}

cout << "Credit Account " << cc->getAccNum() << " was re-opened." << endl;

}

do

{

cout << "Your Credit Limit is " << cc->getCredLimit() << endl;

cout << "Account: " << cc->getAccNum() << " Outstanding Balance: " << cc->getBalDue()

<< " Credit Limit: " << cc->getCredLimit() << " Available Credit: " << cc->credAvailable() << endl;

cout << " Transaction Options" << endl;

cout << "0. Quit 1. New Charge 2. Payment 3. Credit Increase Request 4. Card History Choice: ";

cin >> answered;

if (cin.fail())

{

cin.clear();

cin.ignore();

}

switch (answered)

{

case 0:

cout << "Thanks for using the credit card simulator!" << endl;

break;

case 1:

cout << "Charge Amount: ";

cin >> chrg;

if ((chrg + cc->getBalDue()) < cc->getCredLimit())

{

cout << "Charge Description: ";

cin.clear();

cin.ignore();

getline(cin, charge_desc);

}

else

{

cout << "You can't chrg that amount. You will exceed your credit limit." << endl;

}

break;

case 2:

cout << "Payment Amount: ";

cin >> payscale;

break;

case 3:

cout << "Request Increase (increments of 100): ";

cin >> incr;

break;

case 4:

break;

default:

cout << "You did not enter bc valid selection";

break;

}

} while (answered != 0);

system("pause");

return 0;

}

Please rate the answer if it helped.....Thankyou

Hope it helps.....

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