# Computer Programming

/* Develop a C program that will determine if a department store customer has exceeded the credit limit
on a charge account. For each customer, the following facts are available:
a) account number
b) Balance at the beginning of the month
c) Total of all items charged by this customer this month
d) Total of all credits applied by this customer's account this month
e) Allowed credit limit
The program should input each of these facts. Calculate the new balance (= 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." */

#include <stdio.h>
#include <stdlib.h>

int main( void )
{
float account_number;
float beginning_balance;
float total_charges;
float total_credits;
float credit_limit;
float balance;
float counter;

/* intialization phase */
total_charges = 0;
total_credits = 0;
account_number = 0;
beginning_balance = 0;
counter = 0;
balance = 0;
credit_limit = 0;

while ( account_number != -1 )
{
printf( "Enter account number ( -1
to end ): \n" );
scanf( "%.2f", &account_number);

if ( account_number != -1 ) {
printf( "Enter beginning
balance: \n" );
scanf( "%.2f",
&beginning_balance);
printf( "Enter total charges:
\n" );
scanf( "%.2f", &total_charges);
printf( "Enter total credits:
\n" );
scanf( "%.2f", &total_credits );
printf( "Enter credit limit:
\n" );
scanf( "%.2f", &credit_limit);
system( "pause" );
}

if ( balance > credit_limit ) {

balance = beginning_balance +
total_charges - total_credits;

printf ( "Account: %.2f \n",
account_number);
printf ( "Credit limit: %.2f \n",
credit_limit);
printf ( "Balance: %.2f \n",
balance);
printf ( "Credit limit exceeded
\n" );
}

system ( "pause" );

return 0;

}

}

Can someone tell me what is wrong with the program because it is not working as it should!! Thanks!

1. 👍
2. 👎
3. 👁
4. ℹ️
5. 🚩
1. You may want to indicate the error message you got, or what is not correct.

Sometimes the messages or symptoms are compiler dependent, so it is also a good idea to indicate the compiler you used.

There is no major problem with the programme. However, you may want to consider the following comments:
1. Account number is usually an integer, so I would declare it as a long type, so it will take up to 9 digits (depending on the compiler).
Do not forget to change the input and output formats to %d.
2. The input format for decimal (float) numbers are simply %f. The user can optionally type in the decimal point followed by as many digits as he wishes.
3. You may have extraneous "pauses", but perhaps you have put them in for debugging purposes.
4. The if statement for testing credit limit should be placed immediately after the calculations, and should include only the printing statement. The calculations should not be affected by the if statement.
5. In case the credit limit is exceeded (or not exceeded), you would print the credit limit remaining (or how much has been exceeded). This will give a confirmation for the client, as is done on credit card statements.

If your problem persists, do indicate the nature of the problem or the error message. The name of the compiler would often help as well.

1. 👍
2. 👎
3. ℹ️
4. 🚩
2. We have the same problem. My prof gave me the output program but not the input. :3

1. 👍
2. 👎
3. ℹ️
4. 🚩
3. #include<iostream>
using namespace std;
int main()
{
int account_number=0;
float beginning_balance=0;
float total_charges=0;
float total_credits=0;
float credit_limit=0;
float balance=0;
float counter=0;

while( account_number != -1 )
{
cout<<" Enter account number (-1 to end): "<<endl;
cin>>account_number;

if ( account_number != -1 )
{
cout<<" Enter beginning balance: "<<endl;
cin>>beginning_balance;
cout<<" Enter total charges: "<<endl;
cin>>total_charges;
cout<<" Enter total credits: "<<endl;
cin>>total_credits;
cout<<" Enter credit limit: "<<endl;
cin>>credit_limit;
}

if ( balance>credit_limit)
{
balance=beginning_balance + total_charges - total_credits;

cout<<" Account: "<<account_number<<endl;
cout<<" Credit Limits: "<<credit_limit<<endl;
cout<<" Balance: "<<balance<<endl;
cout<<" Credit Limit Exceeded";
}
}

}

1. 👍
2. 👎
3. ℹ️
4. 🚩

## Similar Questions

1. ### Math

A garden store has the following miscellaneous flower bulbs in a basket: 5 amaryllis 6 daffodils 4 lilies 3 tulips A customer bought 4 bulbs from the basket, one of each type of flower. If the next customer selects 1 of the

2. ### Math

A certain department store requires its credit-card customers to pay interest on unpaid bills at the rate of 18% per year compounded monthly. If a customer buys a television set for \$500 on credit and makes no payments for one

3. ### Algebra

A garden store has the following miscellaneous bulbs in a basket: 5 amaryllis 6 daffodils 4 lilies 3 tulips A customer bought 4 bulbs from the basket, one of each type of flower. If the next customer selects 1 of the remaining

4. ### C++

A small business wants to create a file to store its customer information. Each record in the file is to contain the following data: customer ID number, first name, last name, city, zip code, and account balance. Write a program

1. ### Programming in Python

A customer in a store is purchasing five items. Design a program in python that asks for the price of each item, and then displays the subtotal of the sale, the amount of the sales tax , and the total. Assume the sales tax is 6

2. ### statistics

Forty-four percent of customers who visit a department store make a purchase. The probability, rounded to four decimal places, that in a random sample of 9 customers who will visit this department store, exactly 6 will make a

3. ### Math

A customer buys for products priced at \$18 \$22 \$35 and \$40 from the same store the customer returns the most expensive product and gets a refund for that one pot out how much money did the customer end up spending at that store

4. ### mathematics

How many different ways could you choose three pants to pack for a weekend trip, if you have 12 pants to choose from? Assume the pants are selected without replacement. a. 12! / 3! b. 12! / 9! c. 12! / 8!⋅4! c. 12! / 9!⋅3! If

1. ### MATHEMATICS

Write a pseudocode that will accept items bought by a customer and place them in the appropriate class based on amounts calculated for the bill. Discounts are applied as follows: Silver – 1% Gold – 5% Platinum – 10% Tax on

2. ### Statistics

The per-store daily customer count (i.e., the mean number of customers in a store in one day) for a nationwide convenience store chain that operates nearly 10,000 stores has been steady, at 900, for some time. To increase the

3. ### Computers

Develop a use case diagram for a department store credit card system. Include at least two actors and four use cases.