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

Develop a C program that will determine if a department store customer has excee

ID: 3602334 • Letter: D

Question

Develop a C program that will determine if a department store customer has exceeded the credit limit on a charge account. For a customer the following facts are available:

1. Account Number

2.   Balance at the beginning of the month

3.   Total of all items charged this month

4. Total of all credits applied to this customer’s account this month

5.   Allowed credit limit

The program should input each of these facts, calculate the new balance = (beginning balance + charges – credits), and determine if the new balance exceeds the customer credit limit. For those customers whose credit limit is exceeded, the program should display the customer’s account number, credit limit, new balance and the message “Credit limit exceeded”.  Otherwise display the same information plus the available credit. At the end of every calculation the program should prompt the user if he/she wants to continue (use a loop to implement this feature).

Explanation / Answer

#include <stdio.h>
#include <stdbool.h>

int main() {
int AccNum;
float BegBal, TotCharges, TotCredits, creditLimit, AccBal;

while(true) {
printf( "Enter account number ( -1 to end ): " );
scanf( "%d", &AccNum );

if ( AccNum == -1 ) {
return 0;
}

printf( "Enter beginning balance: " );
scanf( "%f", &BegBal );
printf( "Enter total charges: " );
scanf( "%f", &TotCharges );
printf( "Enter total credits: " );
scanf( "%f", &TotCredits );
printf( "Enter credit limit: " );
scanf( "%f", &creditLimit );

AccBal = BegBal + TotCharges - TotCredits;

if ( AccBal > creditLimit ) {
printf( "Account: %d ", AccNum );
printf( "Credit Limit: %.2f ", creditLimit );
printf( "Balance: %.2f ", AccBal );
printf( "Credit limit exceeded. " );
}
}

return 0;
}