Almost Got It, I think

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Dec 2007
Posts: 10
Reputation: Dean_X is an unknown quantity at this point 
Solved Threads: 0
Dean_X Dean_X is offline Offline
Newbie Poster

Almost Got It, I think

 
0
  #1
Dec 1st, 2007
Here is my problem. I have searched everywhere for help on this one. I haven't found any. So, I sat down and tried the best I could to write this code: Now I am stuck:

Here is what I have so far:
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <fstream>
  4. using namespace std;
  5.  
  6. int main ()
  7.  
  8. {
  9. ifstream inFile;
  10. int custID, newBal, intRate;
  11. cout.precision(2);
  12. inFile.open("cardholders.txt");
  13. cout << "Reading information from the file.\n\n";
  14.  
  15. inFile >> custID;
  16. inFile >> newBal;
  17. inFile >> intRate;
  18.  
  19. {
  20. // Make sure we use types that hold decimal places
  21. double custID, minPay, curBal, newBal, lateFee, intRate, Y, N;
  22.  
  23. cout << "What is your current balance:";
  24. cin >> curBal;
  25. if (curBal<10.00)
  26. minPay = curBal;
  27. else (curBal>10.00);
  28. minPay = curBal * 0.15;
  29.  
  30. cout << "Was payment late:";
  31. cin >> Y or N;
  32. if (lateFee = N)
  33. lateFee = minPay;
  34.  
  35. else (lateFee = Y);
  36. }
  37. else (curBal < 40)
  38. minPay = minPay + 15;
  39. else (curBal > 40 && < 100)
  40. minPay = minPay + 30;
  41. else (curBal > 100)
  42. minPay = minPay + 45;
  43. return 0;
  44. }
  45. {
  46. cout << "Enter current balance:";
  47. cin >> curBal;
  48. cout<<" Enter Late Fee:";
  49. cin >> lateFee;
  50. cout << "Enter Current Payment:";
  51. cin >> minPay;
  52. cout << "New Balance is:";
  53. cout << (curBal + lateFee) - minPay << endl;
  54.  
  55.  
  56. cout << "File written to, and now being closed..." << endl;
  57.  
  58. outputFile.close();
  59. cout << "Done.\n";
  60.  
  61. {
  62. {
  63. ifstream inFile;
  64. int custID, newBal, intRate;
  65. inFile.open("cardholders.txt");
  66. cout << "Reading information from the file.\n\n";
  67.  
  68. inFile >> custID;
  69. inFile >> newBal;
  70. inFile >> intRate;
  71.  
  72. // Process Customer 1
  73. inFile >> custID;
  74. inFile >> newBal;
  75. inFile >> intRate;
  76. cout << "Customer ID 1: " << newBal << intRate << endl;
  77.  
  78. // Process Customer 2
  79. inFile >> custID;
  80. inFile >> newBal;
  81. inFile >> intRate;
  82. cout << "Customer ID 2: " << newBal << intRate << endl;
  83.  
  84. // Process Customer 3
  85. inFile >> custID;
  86. inFile >> newBal;
  87. inFile >> intRate;
  88. cout << "Customer ID 3: " << newBal << intRate << endl;
  89.  
  90. // Process Customer 4
  91. inFile >> custID;
  92. inFile >> newBal;
  93. inFile >> intRate;
  94. cout << "Customer ID 4: " << newBal << intRate << endl;
  95.  
  96. // Process Customer 5
  97. inFile >> custID;
  98. inFile >> newBal;
  99. inFile >> intRate;
  100. cout << "Customer ID 5: " << newBal << intRate << endl;
  101.  
  102. // Close the file
  103. inFile.close();
  104. cout << "\nDone.\n";
  105.  
  106. system("PAUSE");
  107. return 0;
  108. }
Heres is what I need it to do:

* The program should read all the records in the file cardholders.txt until the end of the file. Each cardholder record contains the customer ID, current balance, and APR.

* For each record read, the program should do the following:
• Calculate the minimum payment due for the next billing cycle. If the current balance is less than $10.00, then the minimum payment will be the current balance. Otherwise, the minimum payment will be the greater of $10.00 or 15% of the current balance.

• Ask the user to enter the amount of the current payment for the customer with this ID. Ask the user whether the payment was late.

• Calculate the late fee. If the payment was not late, there will be no late fee.
For late payments:

• If the current balance is less than $40, the late fee will be $15.
• If the current balance is in the range from $40 to $100, the late fee will be $30.
• If the current balance is over $100, the late fee will be $45.

• Use a function called NewBalance to calculate the customer’s new balance. (You must create this function.) The function NewBalance will accept the APR, late fee, current balance, and current payment as input parameters and return the customer’s new balance.

• Store the data for this customer in three parallel arrays, custID, newbal, and minpay. These three arrays should respectively hold each customer’s ID, new balance, and minimum payment.

After all the records in the cardholders.txt file have been processed, the program should display a report with three columns showing each customer’s ID, new balance, and minimum payment. The columns should be aligned appropriately. The new balance and minimum payment should be displayed in currency format with 2 fixed decimal places.

Where do I go from here? I am literally stuck.

Forgive me, but I am just trying to get through this without going nuts. I am an IT major. I have to take these classes as part of my core. I am almost done with all of it. I have been doing great up to this one and it is kicking my rear. I have been looking at code for what seems like an eternity. Unfortunately, I also had to take webpage class this semester and sometimes it seems the code from one runs on to the other. I am just trying to survive this class. I have an "A" in the class as of right now, but at this point I will settle for a "B". I am just frustrated with this whole thing.

Sorry for venting. Thanks for all of your help.

OK, now, how can you help me?

Oh, and btw, Can you run the 3 parrellel code for me with attached file? It is working but output is wrong.
Last edited by cscgal; Dec 1st, 2007 at 8:29 pm. Reason: Added code tags
Attached Files
File Type: txt cardholders.txt (66 Bytes, 3 views)
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 1,688
Reputation: Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all 
Solved Threads: 265
Lerner Lerner is offline Offline
Posting Virtuoso

Re: Almost Goy It, I think

 
0
  #2
Dec 1st, 2007
Your code is almost impossible to read due to poor formatting. Learning how to format with consistent and appropriate indentation will save you lots of time trying to debug and make it easier for others trying to help or trying to maintain your code.

I don't see where you declare outfile at all, so trying to close it is definitely a no-no.

I don't see any arrays as called for in the instructions.

I don't see any functions as called for in the instructions.

First thing I'd do is comment everything out of the code from this line down:

inFile >> intRate;

Then develop a loop to read the entire file, outputting at least one set of information to be sure you're reading it in correctly. Once you've got that you can proceed further.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 10
Reputation: Dean_X is an unknown quantity at this point 
Solved Threads: 0
Dean_X Dean_X is offline Offline
Newbie Poster

Re: Almost Goy It, I think

 
0
  #3
Dec 1st, 2007
You are kidding, right? I am only doing this because I have to. As soon as I am done with this class I am done with programming. The main reason for this attitude is that I know a few people that are programmers. Outside of being good programmers, they are good for anything else. They are lousy teachers because they dont know how to get past their own arrogance. So, a far an really wanting to get to know this stuff, I will pass. I will do just enough to get my "A" and move on. Thank you.
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 3,114
Reputation: WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of 
Solved Threads: 281
Moderator
WaltP's Avatar
WaltP WaltP is offline Offline
Posting Sensei

Re: Almost Goy It, I think

 
0
  #4
Dec 2nd, 2007
Originally Posted by Dean_X View Post
You are kidding, right?
Kidding about what? I don't understand what you mean. Let's look at what Lerner said:
Originally Posted by Lerner View Post
Your code is almost impossible to read due to poor formatting. Learning how to format with consistent and appropriate indentation will save you lots of time trying to debug and make it easier for others trying to help or trying to maintain your code.
You want help but don't want to make your code readable? Why not write it in Swahili then.

Originally Posted by Lerner View Post
I don't see where you declare outfile at all, so trying to close it is definitely a no-no.
This is a definite error in your code. It can't run correctly without it.

Originally Posted by Lerner View Post
I don't see any arrays as called for in the instructions.
You can't pass if you don't follow the instructions.

Originally Posted by Lerner View Post
I don't see any functions as called for in the instructions.
You can't pass if you don't follow the instructions.

Originally Posted by Lerner View Post
First thing I'd do is comment everything out of the code from this line down:

inFile >> intRate;

Then develop a loop to read the entire file, outputting at least one set of information to be sure you're reading it in correctly. Once you've got that you can proceed further.
A reasonable suggestion, so YOU can figure out what your code is doing.

So no, Lerner is not kidding. Are you saying that as an IT Major you don't need to learn any programming? This is news to me. Even so, we don't write code for people here, even if all they want to do is skate through their course without learning anything.
The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,266
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: Almost Goy It, I think

 
0
  #5
Dec 2nd, 2007
> I have an "A" in the class as of right now, but at this point I will settle for a "B".

In that case your teachers must be clowns and your school must actually be a circus, because at the moment all I see is a big attitude with no signs of intelligence at all.

> I already figured that one out. Jeez! It really sux when a
> person like me, in their 40's,

If you behave like this in your 40's then I would hate to have seen what you behaved like when you were younger.

> PS. My code doesnt work, just thought I would let you know.

Well duh! When you decide to actually put some of your own effort into this, drop the attitude and realise that these people here are giving up their free time to help you, you'll get all the help you'll need honey.

And I'll let you into a trade secret. If you include the header file #include "verySmallViolins" your teacher just might pass you on the grounds of sympathy.
Last edited by iamthwee; Dec 2nd, 2007 at 7:50 am.
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 4
Reputation: boB_K7IQ is an unknown quantity at this point 
Solved Threads: 1
boB_K7IQ boB_K7IQ is offline Offline
Newbie Poster

Re: Almost Goy It, I think

 
0
  #6
Dec 2nd, 2007
I'm not trying to sound like a prick here, but shouldn't

if (lateFee = N)

be

if (lateFee == N)

?

boB
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 3,114
Reputation: WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of 
Solved Threads: 281
Moderator
WaltP's Avatar
WaltP WaltP is offline Offline
Posting Sensei

Re: Almost Goy It, I think

 
0
  #7
Dec 2nd, 2007
Dean, please explain what was wrong with the first response you received? Lerner's assessment was right on. I guess my question is in your first post did you follow all the suggestions in the post titled Read Me: Read This Before Posting? If you can honestly say yes, we're sorry. If you can't, post a question that we have a reasonable chance of answering.
The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 10
Reputation: Dean_X is an unknown quantity at this point 
Solved Threads: 0
Dean_X Dean_X is offline Offline
Newbie Poster

Re: Almost Goy It, I think

 
0
  #8
Dec 2nd, 2007
I already did that. I pasted my entire assignment in my first post. I pasted my code and the errors I received. All I got was, "your code is wrong." Isnt that the whole point in bringing my problem to this forum. If my code was right, I wouldnt need to post it, now would I?
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,734
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 738
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: Almost Goy It, I think

 
0
  #9
Dec 2nd, 2007
>All I got was, "your code is wrong."
That's an exaggeration. You received help for figuring out what's wrong with your code as well as for helping us to help you more. Then you started whining about how we're pricks (probably because we didn't point out every single problem and fix it for you). Tell me this: why should you expect us to help you when you clearly don't respect us enough to listen?
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 4
Reputation: boB_K7IQ is an unknown quantity at this point 
Solved Threads: 1
boB_K7IQ boB_K7IQ is offline Offline
Newbie Poster

Re: Almost Goy It, I think

 
0
  #10
Dec 2nd, 2007
Since you say you are not interested in how the program works, I can only assume that you
really aren't interested in the subject of computers and IT very much. Because of that,
you may not last long in this industry. I wouldn't hire anyone that didn't like their job.

boB
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC