Develop a C program that will determine if a department store customer has excee
ID: 3538671 • 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%u2019s account this month
5. Allowed credit limit
The program should input each of these facts, calculate the new balance = (beginning balance + charges %u2013 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%u2019s account number, credit limit, new balance and the message %u201CCredit limit exceeded%u201D. 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 #include int main(void) { long int ac; double begBal,tot,creds,lim,newBal; char resume='y'; while(resume=='y') { printf(" Please enter the following: "); printf("Enter Account Number: "); scanf("%ld",&ac); printf("Enter Balance at the beginning of the month: "); scanf("%lf",&begBal); printf("Enter Total of all items charged this month: "); scanf("%lf",&tot); printf("Enter Total of all credits applied to your account this month: "); scanf("%lf",&creds); printf("Enter Allowed credit limit: "); scanf("%lf",&lim); newBal= begBal + tot - creds; printf(" Account Number: %ld ",ac); printf("Credit Limit: %.2f ",lim); printf("New Balance: %.2f ",newBal); if(newBal>lim) { printf("Credit limit exceeded "); } else { printf("Available credit: %.2f ",(newBal-lim)); } fflush(stdin); printf(" Do you want to continue? (y/n): "); } return 0; }Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.