C++ Write a member function ChargeTheCard of struct CreditCard which is used to
ID: 3865984 • Letter: C
Question
C++
Write a member function ChargeTheCard of struct CreditCard which is used to simulate customer using the credit card to shop or make purchases. As you know that available credit on your credit card is defined by the following expression:
availableCredit = CreditLimit – balance
The credit card charging software makes sure that your purchase does not exceed available credit. If it does then the purchase must be denied. If the amount of purchase is less than or equal to available credit, then purchase is allowed and balance is increased by the amount of purchase. Write the ChargeTheCard function such that above standard is enforced.
void ChargeTheCard(double purchaseAmount)
{
)
Explanation / Answer
Hi,
Please find below the code-
void ChargeTheCard(double purchaseAmount)
{
if(availableCredit < purchaseAmount)
{
cout<<"Your Purchase Amount exceeds your total available credit. Please provide lower Amount";
}
else if(availableCredit >= purchaseAmount)
{
availableCredit=availableCredit-purchaseAmount
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.