Hi, I need help from anyone to solve this "c programming" or help to teach the method for this question. thank u so much?
A bookstore has many customers and each one of them has an account with a credit limit which
must not be exceeded. The bookstore owner requested you to develop a system by using C programming
language to control these accounts.
For each customer, the following facts are available:
1. Account Number
2. Balance at the beginning of the month
3. Total of all items charged by this customer 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 (which is the beginning balance
+ charges – credits), and determine if the new balance exceeds the customer’s 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”
------------------------------------------------------------------------------------------------------------------.
A sample output is shown below,
Enter account (-1to end): 3
Enter Beginning Balance: 3500
Enter Total Charges: 750
Enter Total Credits: 300
Enter credit Limits: 4000
Account: 100
Balance: 3950

Enter account (-1to end): 15
Enter Beginning Balance: 2200
Enter Total Charges: 1000
Enter Total Credits: 300
Enter credit Limits: 2500
Account: 15
Balance: 2900
Credit Limit Exceeded

Enter account (-1to end): -1
Program Terminated

Recommended Answers

All 3 Replies

Hi Tena, welcome here at DaniWeb! :)
Please show us what you already did, even if it is totally wrong and you are stuck.
Nobody here is going to help you by just posting an assignment.
Please read the rules.

A simple method to get you started is always to carefully read the question over and compare that to 'the example output' ...

(Your question and example output are really very well given to you ... and you could start out with a small working shell first step program ... that might be to code just to enter one data set - one struct ...
and then to print that record back to the screen.)

You could use a C struct to hold your data.

It could look like this:

typedef struct
{
   int accountNo;
   int startBalance;
   int totalCharges;
   int totalCredits;
   int creditLimit;
} AccountInfo ;

/* a few functions ... like one to fill up a struct */

/* example of function prototypes you could use */
void takeInAccInfo( Account* acc );
void calAndPrintAccInfo( Account* acc );
int more();
/* you could use others also ... */

/* NOTE": you must define these before using */

/* then in main */

/* start taking in one record and reporting ... */
int main()
{
    do
    {
        AccountInfo tmp; /*get memory to hold info*/
        takeInAccInfo( &tmp ); /* pass in address */
        calAndPrintAccInfo( &tmp ); 
    }
    while( more() );

    return 0;
}

/* // so this can guide all your input prompts
Enter account (-1to end): 3
Enter Beginning Balance: 3500
Enter Total Charges: 750
Enter Total Credits: 300
Enter credit Limits: 4000

*/

/* //and this will quide your output (after calculations)
Account: 100
Balance: 3950
*/

Your question and example output are really very well given to you ...

Oops ... that is NOT the case ... the example output given when the balance exceeds the credit limit does not match the written spec's.

I would GO WITH the written spec's.

Thus the example (of last lines of) output when the new balance exceeded the credit limit should have looked like this:

Account: 15
Limit  : 2500
Balance: 2900
Credit limit exceeded

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"

Also ... your function:

/* return value is 1 to continue or 0 to quit */
int takeInAccInfo( AccountInfo* acc );

rather than have a 'void' return value should rather return an 'int' ...
(as per the comment line above the function prototype)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.