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

C++ The data members for struct CreditCard are given below. Write its default an

ID: 3865983 • Letter: C

Question

C++

The data members for struct CreditCard are given below. Write its default and explicit constructors. Assume that all necessary includes have been done.

A]. Default constructor must initialize various data members as below:

firstName to a value “First Name not set”.

lastName to a value “Last Name not set”.

CCN to 0

Balance to 0.0

CreditLimit to 1500.00.

You can set a global constant for credit limit. Global constants are visible throughout the program after the line of their declaration.

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

struct CreditCard

{

string firstName;// Customer first name

string lastName; // Customer last name

int CCN; // Credit Card Number

double balance;// Positive if customer owes the

not exceed this value

CreditCard( )// Default constructor

{

// Fill in the body of default constructor. Use values given in item A above to initialize data members

}

//Fill in the body of explicit constructor below. Set balance to zero and CreditLimit to 1500.00

CreditCard(string fname, string lname, int cardNum)

{

//fname initializes the customer firstName

//lname initializes the customer lastName

//cardNum initializes the CCN

}

};// end of struct CreditCard

Instructor initials on completion:

Explanation / Answer

Answer for the given Question:

See the below code update as per given problem statement initaized and defualt and explicit constructor.

f

#include<cstring>

#include<iostream>

using namespace std;

//Setting CreditLimit to 1500.00. gloable

double CreditLimit = 1500.00;

struct CreditCard

{

string firstName;// Customer first name

string lastName; // Customer last name

int CCN; // Credit Card Number

double balance;// Positive if customer owes the not exceed this value

CreditCard( )// Default constructor

{

// Fill in the body of default constructor. Use values given in item A above to initialize data members

firstName = "First Name not Set";

lastName ="Last Name not set";

CCN = 0;

balance = 0.0;

}

//Fill in the body of explicit constructor below. Set balance to zero and CreditLimit to 1500.00

CreditCard(string fname, string lname, int cardNum)

{

//fname initializes the customer firstName

firstName = fname;

//lname initializes the customer lastName

lastName = lname;

//cardNum initializes the CCN

CCN = cardNum;

}

};// en

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