Write a C program that allows the user to balance a credit card account. The program should first prompt the user to enter the Bank Name, and the beginning balance of his/her credit card account (must allow for dollars and cents). The program should then prompt the user to enter the number of refunds to be posted, and then the number of payments to be posted, and then the number of charges to be posted. For this assignment, let's set a maximum of 30 transactions of any of those types, you'll see why as you read on.
Using a loop, the program should then prompt the user to enter the amount of the first refund (a positive amount to add to the credit card account balance), the amount of the second, the third, & etc., until the number of refunds are processed.
Using a second loop, the program should then prompt the user to enter the amount of the first payment (a positive amount to add to the credit card account balance), then amount of the second, the third, etc. until the number of payments have been processed.
Using a third loop, the program should then prompt the user to enter the amount of the first charge (a positive amount to be subtracted from the credit card account balance), then amount of the second, the third, etc. until the number of charges have been processed. Once all charges and refunds and payments have been made, the program should output the Reconciliation report.
Read all the specifications carefully. I did not show all the editing features you are required to do, but they are in bold above.
The dialog with the user should look exactly as the following, only with your special introductory statement as you wish:
Welcome to the Sears Credit Card Accounting System
First, enter the name of the Bank: First Federal
Now enter the First Federal Credit Card balance in dollars and cents: -200.33
Enter the number of refunds to post: 44
Error: Number of refunds must be at most 30, please re-enter.
Enter the number of refunds to post: 2
Enter the number of payments to post: 1
Enter the number of charges to post: 4
Enter the amount of refund #1: 12
Enter the amount of refund #2: 13.22
Enter the amount of payment #1: -33.00
Error: Payment amount must be greater than zero, please re-enter.
Enter the amount of payment #1: 33.00
Enter the amount of charge #1: 111
Enter the amount of charge #2: 272
Enter the amount of charge #3: 11.55
Enter the amount of charge #4: 27.45
First Federal Reconciliation Report
---------------------------------------------
Starting Balance: $ -200.33
refund # 1: 12.00
refund # 2: 13.22
payment # 1: 33.00
charge # 1: 111.00
charge # 2: 272.00
charge # 3: 11.55
charge # 4: 27.45
Ending Balance: $ -564.11
There must be data validation on all user numeric input, and proper trap loops need to be used. These are discussed in the notes and examples are there as well as in the chats. It is hard to see in this document, but I want you to align the decimal points in the account reconciliation summary report. You are to keep track of all the refunds, payments and charges so that you can print them out in reconciliation form. You do this by storing them in arrays. You want to be sure that the size of the arrays are large enough to handle 30 of each transaction. Perhaps: float refunds[30], charges[30], payments[30];
Dear Student here is your required code.
Code
__________________________________________________________________________
#include<stdio.h>
int main(){
float refunds[30],charges[30],payments[30];
float balance;
int nref,npay,ncha,i=0,j=0,k=0,x=0;
char name[100];
printf("Welcome to the Sears Credit Card Accounting
System\n");
printf("First,enter the name of the bank: ");
scanf("%[^\n]%*c", name);
printf("Now enter the ");
printf("%s",name);
printf(" Credit Card balance in dollars and cents:
");
scanf("%f",&balance);
printf("Enter the number of refunds to post: ");
scanf("%d",&nref);
while(nref>30){
printf("Error: Number of refunds must be at most 30,
please re-enter.\nEnter the number of refunds to post: ");
scanf("%d",&nref);
}
printf("Enter the number of payments to post:
");
scanf("%d", &npay);
printf("Enter the number of charges to post: ");
scanf("%d", &ncha);
for( i=1;i<=nref;i++){
printf("%s %d %s","Enter the amount
of refund #",i,": ");
scanf("%f",&refunds[i]);
while(refunds[i]<0){
printf("\nError:refund amount must
be greater than zero, please re-enter.");
scanf("%f",&refunds[i]);
}
}
for( j=1;j<=npay;j++){
printf("%s %d %s","Enter the amount
of payment #",j,": ");
scanf("%f",&payments[j]);
while(payments[j]<0){
printf("Error:payment amount must
be greater than zero, please re-enter.");
scanf("%f",&payments[j]);
}
}
for( k=1;k<=ncha;k++){
printf("%s %d %s","Enter the amount
of charge #",k,": ");
scanf("%f",&charges[k]);
while(charges[k]<0){
printf("\nError:charge amount must
be greater than zero, please re-enter.");
scanf("%f",&charges[k]);
}
}
printf("%s %s",name,"Reconciliation
Report\n---------------------------------------------");
printf("%s %.2f","\nStarting balance:$
",balance);
for(x=1;x<=nref;x++){
printf("%s %d %s %.2f","\nrefund #
",x,": ",refunds[x]);
balance+=refunds[x];
}
for(x=1;x<=npay;x++){
printf("%s %d %s %.2f","\npayment #
",x,": ",payments[x]);
balance+=payments[x];
}
for(x=1;x<=ncha;x++){
printf("%s %d %s %.2f","\ncharge #
",x,": ",charges[x]);
balance-=charges[x];
}
printf("%s %.2f","\nEnding Balance:$ ",balance);
}
__________________________________________________________________________
Here is sample output
If it helps then please rate my answer and for further clarification put a comment.
Get Answers For Free
Most questions answered within 1 hours.