Question: Write a C program that allows the user to make some ledger transactions. The program should first prompt the user to enter the current balance
Write a C program that allows the user to make some ledger transactions. The program should first prompt the user to enter the current balance of his/her ledger account (must allow for dollars and cents, and not less than zero). The program should then prompt the user to enter the number of debits to be posted, and then the number of credits to be posted. For this assignment, let's set a maximum of 50 credits or debits, 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 credit (a positive amount to add to the ledger balance), the amount of the second, the third, & etc., until the number of credits have been processed. Using a second loop, the program should then prompt the user to enter the amount of the first debit (a positive amount to be subtracted from the ledger balance), then amount of the second, the third, etc. until the number of debits have been processed. Once all credits and debits have been made, the program should output the ledger balance. Read all the specifications carefully. I did not show all of the editing features you are required to do, but they are in bold above. The dialog with the user should look similar to the following, only with your special introductory statement(s) as you wish: Welcome to the Sears Accounting System First, enter the name of the Account: Electrical Now enter the Electrical balance in dollars and cents: 200.55 Enter the number of debits: 2 Enter the number of credits: 55 Error: Number of credits must be at most 50, please re-enter. Enter the number of credits: 7 Enter the amount of credit #1: 12 Enter the amount of credit #2: 13.22 Enter the amount of credit #3: 11 Enter the amount of credit #4: 40 Enter the amount of credit #5: 33 Enter the amount of credit #6: 22.22 Enter the amount of credit #7: 33 Enter the amount of debit #1: 111 Enter the amount of debit #2: 222 *** The closing balance is $31.99 *** *** Account Electrical Summary *** Starting Balance: $ 200.55 credit # 1: 12.00 credit # 2: 13.22 credit # 3: 11.00 credit # 4: 40.00 credit # 5: 33.00 credit # 6: 22.22 credit # 7: 33.00 debit # 1: 111.00 debit # 2: 222.00 Ending Balance: $ 31.99 The should be error checking on all user input, and trap loops need to be used. These are discussed in the notes and examples are there as well as in the google documents. It is hard to see this in HTML document, but I want you to align the decimal points in the account summary. You are to keep track of all of the credits and debits so that you can print them out in "record" 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 50 credits and 50 debits. Perhaps:
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
