Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PROGRAM #5 This program is similar to programming assignment #4: Data error checking is required for all inputs, as in #4. Your program is to

PROGRAM #5

This program is similar to programming assignment #4: Data error checking is required for all inputs, as in #4. Your program is to behave in the exact same manner as assignment #4, however how you structure your code is a different story. Now we will use functions. Hmmmmmmm, I think I remember Assignment #4, lets see 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... (etc. Go Back and Read the specs. for program number 4)

Here is the change for program #5: There should be at least three non-trivial functions in the program! (by that I mean 3 functions that do more than just print a line of text, and they must accept data in from main or return data out to main). For example, one function may be to find out how many credits will be entered, or another may get the opening balance, or another for the account name. You may choose how to apply the functions. Hints: Your code from assignment #4 does not need to be modified too much to solve this problem. The algorithm is the same. Outputting the contents of the arrays in "ledger summary form" is pretty straightforward, and should be done in a loop. (This could be another good place for a function.) T Furthermore, if you use more than three functions, I will grant you some minor errors that I would normally take off for (-2 or -3 points) for each function used (to a maximum of 100 for a grade). Now that's an incentive!

===============================================================================================================================

Now, we are using thesame below information as last assignment #4 but the structure code will use FUNCTION in program #5

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

There should be error checking on all user input, and trap loops need to be used. 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: float credits[50], debits [50];

Thanks for your help!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Management Databases And Organizations

Authors: Watson Watson

5th Edition

0471715360, 978-0471715368

Students also viewed these Databases questions

Question

Question Can I collect benefits if I become disabled?

Answered: 1 week ago

Question

Question May I set up a Keogh plan in addition to an IRA?

Answered: 1 week ago