944,117 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 2225
  • C++ RSS
Nov 10th, 2004
0

assignment needs a little help, well i do

Expand Post »
1) Read an integer # from the file balance.dat that represents the balance on your checkbook (Assume integer #'s only)
2)let the user enter an amount to write a check.
3)If there is enough balance to write teh check then display the message (OK to write check) if the check is overdraft 350.00, from 1-50 dollars then the bank charges 5 dollars more to cash the check so display message (OK to write check , but 5 dollars will be charged due to NSF)
4) remember to chekc if the file exists before you do anything (usethe .fail() function)
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Intro2Prog is offline Offline
5 posts
since Nov 2004
Nov 10th, 2004
0

Re: assignment needs a little help, well i do

Okay, what part are you having trouble with? Keep in mind that if you say you haven't done anything yet, I'll tell you to get lost. If you have done something, you'll need to prove it. Why? Because this is obviously homework, it's obviously easy if you put in a little effort, and maybe I just don't like you.
Administrator
Reputation Points: 6442
Solved Threads: 1393
Bad Cop
Narue is offline Offline
11,807 posts
since Sep 2004
Nov 10th, 2004
0

Re: assignment needs a little help, well i do

well ofcourse i have but right now i'm late for work, i will post my work in a while
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Intro2Prog is offline Offline
5 posts
since Nov 2004
Nov 10th, 2004
0

Re: assignment needs a little help, well i do

Quote originally posted by Narue ...
Okay, what part are you having trouble with? Keep in mind that if you say you haven't done anything yet, I'll tell you to get lost. If you have done something, you'll need to prove it. Why? Because this is obviously homework, it's obviously easy if you put in a little effort, and maybe I just don't like you.


here's what i have
C++ Syntax (Toggle Plain Text)
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <fstream>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. int checkAmount;
  10. ifstream inBalance;
  11. ofstream outBalance;
  12.  
  13. inBalance.open("balance.dat");
  14.  
  15. if (inBalance.fail())
  16. {
  17. cout << "file balance.dat not found !!!!" << endl;
  18. getch ();
  19. exit(1);
  20. }
  21.  
  22. cout << "Please enter check amount: ";
  23. cin >> checkAmount;
  24.  
  25. if (inBalance <= 350)
  26. {
  27. cout << "ok to write check" << endl;
  28. }
  29.  
  30. if (inBalance >= 350)
  31. {
  32. cout << "OK to write check but 5 dollars will be charged due to NSF " << endl;
  33. }
  34.  
  35. if (inBalance > 100)
  36. {
  37. cout << "the bank will not pay this check" << endl;
  38. }
  39.  
  40. cout << endl;
  41.  
  42. outBalance.open("balance.dat")
  43.  
  44. getch();
  45. return 0;
  46.  
  47. }
Last edited by alc6379; Nov 12th, 2004 at 12:48 pm. Reason: added [code] tags
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Intro2Prog is offline Offline
5 posts
since Nov 2004
Nov 10th, 2004
0

Re: assignment needs a little help, well i do

Very close, but inBalance is a stream, not an integer. After you open the file, do something like this:
C++ Syntax (Toggle Plain Text)
  1. int balance;
  2. inBalance>> balance;
Then use balance and checkAmount for your conditional statements.
Administrator
Reputation Points: 6442
Solved Threads: 1393
Bad Cop
Narue is offline Offline
11,807 posts
since Sep 2004
Nov 12th, 2004
0

Re: assignment needs a little help, well i do

can anyonehelp me



C++ Syntax (Toggle Plain Text)
  1.  
  2. #include <iostream>
  3. #include <conio.h>
  4. #include <fstream>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. int Amount;
  11. int balance;
  12.  
  13. ifstream inAmount;
  14. ofstream outAmount;
  15.  
  16. inAmount.open("balance.dat");
  17.  
  18. inBalance >> balance;
  19.  
  20. if (inBalance.fail())
  21. {
  22. cout << "file balance.dat not found!!!" << endl;
  23. getch();
  24.  
  25. }
  26.  
  27. cout << "Please enter check amount: ";
  28. cin >> Amount;
  29.  
  30. if (balance <=350)
  31. {
  32. cout << "Ok to write check" << endl;
  33. }
  34.  
  35. if (balance >=350)
  36. {
  37. cout << "The bank will not pay this check" << endl;
  38. }
  39.  
  40. cout << endl;
  41.  
  42. outBalance.open("balance.dat")
  43.  
  44. getch();
  45. return 0;
  46.  
  47. }
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Intro2Prog is offline Offline
5 posts
since Nov 2004
Nov 12th, 2004
0

Re: assignment needs a little help, well i do

Whats wrong here? Are you having a problem or do you expect someone to write the program for you?
Reputation Points: 11
Solved Threads: 2
Junior Poster in Training
jasweb2002 is offline Offline
56 posts
since Sep 2004
Nov 12th, 2004
0

Re: assignment needs a little help, well i do

>can anyonehelp me
I did help you. If you have a new question then ask it. The logic for this program is simple, so either you're very stupid, or very lazy. I prefer to assume the latter, so explain exactly what your problem is and we'll help. But we won't do it for you.
Administrator
Reputation Points: 6442
Solved Threads: 1393
Bad Cop
Narue is offline Offline
11,807 posts
since Sep 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: priority queue
Next Thread in C++ Forum Timeline: program w/ switch AND nested if. six error messages





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC