![]() |
| ||
| frustrated newbie needs help Develop a C++ program that will determine whether a department-store customer has ex-ceeded the credit limit on a charge account. For each customer, the following facts are available: a. account number (an integer) 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 to this customers account this month e. allowed credit limit The program should use a while structure to input each of these facts, calculate the new balance(=beginning balance + charges - credits) and determine whether the new balance exceeds the customer's credit limit. For those customers whose credit limit is exceeded, the program should display the customers account number, credit limit, new balance and the message "Credit Limit exceeded". If anyone could hook me up with the solution it would save me from going crazy |
| ||
| You say that for each customer a bunch of info is available. Is this info stored as a struct or a class? (I don't know if you're familiar at all with object oriented programming. If not, just ignore this question b/c it won't make much sense to you.) I don't see how you would use a while loop to input those five properties of the user. Perhaps: int enterInfo=0; That doesn't make much sense to me though. Perhaps the program deals with one user after another, and it loops in a while loop until account number is -1 or something? Here's a quick sketch of doing it that way: do |
| ||
| Once again, I'm not sure if this is what you're looking for. Maybe someone else would be able to give you a hand here in the forums. Otherwise, drop me an IM via AIM. |
| ||
| Dani has already provided the basis of a solution. I think it's equally as important to understand *how* you come up with a solution to problems such as this. You need an approach to problem solving. There's no rocket science involved; you simply need to go through your problem statement, break it down into steps, refine the steps, then implement those steps as C++ code. Let's work it through. We know from the first paragraph that our program is going to deal with customers, multiple customers, and that for each the following information is required: Account Number Balance at start of month Total monthly charge Total monthly credits Credit limit We can already envisage the use of variables for these, e.g. int accountNumber; double startBalance; double monthlyCharge; double monthlyCredit; double creditLimit; but that's a level of detail that we don't need to worry about yet. In the second paragraph it says we should use a while structure to input those values, calculate the new balance, check if the credit limit has been exceeded, if it has display the customer details and a warning message. This paragraph describes the steps we need, so let's list them, it will form the basis of our solution (Stage 1): 1. Loop while we have more customers 2. Read in the customer details 3. Calculate the customer's new account balance 4. If the limit has been exceeded 5. Output the customer account details and warning message 6. end if 7. end loop That's a very simple form of pseudocode, in English. A basic design, if you like, for our solution. Now we refine those steps a little in Stage 2: 1. Loop while we have more customers 2.1 Input the Account Number 2.2 input the balance at start of month 2.3 Input the total monthly charge 2.4 Input the total monthly credit 2.5 Input the credit limit 3. Set new balance to start balance - charges + credits 4. If new balance is greater than credit limit 5.1 Output account number 5.2 Output credit limit 5.3 Output new balance 5.4 Output "Credit Limit Exceeded" 6. End if 7.1 Prompt for more customers 7.2 End loop We can refine a number of these steps further, Stage 3, for example: 2.1 Input account number becomes: 2.1.1 Prompt for account number 2.1.2 Read in account number and so on. We may refine some steps several more times (and others not at all). Once we have refined these steps sufficiently we start to translate them to code (Stage 4). Here's an example that matches the steps above, with some implementation tweaks. bool moreCustomers=true; That's a simplified approach (and the code hasn't been tested, it's the approach that matters) but you get the idea. It's really a question of designing the solution before you code it. Can you see how the design was taken straight from the problem statement and broken down into simple steps, then refined, then coded? Later you'll want to use more sophisticated design techniques, but this should help you to understand how to tackle new problems, even if you don't have a clue how to code it at the start. By the way, using this method you might find that you can code 4 or 5 of the steps yourself but that, for instance, the remaining steps are unclear to you because you're still learning. You can then post the code you have and people will help you with the gaps. Good luck. |
| ||
| Re: frustrated newbie needs help hey i have that same problem except mine is in VB and i can't seem to get it neither!!! im sooo FRUSTRATED i see the logic but it is hard to decipher into VB text |
| ||
| Re: frustrated newbie needs help Perhaps you should ask your question with a new thread in the VB forum instead of resurrecting a four year old C++ thread. kthnxbye. |
| ||
| Re: frustrated newbie needs help Quote:
|
| All times are GMT -4. The time now is 1:43 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC