back again sorry but need help starting problem

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

Join Date: Feb 2008
Posts: 5
Reputation: micah1983 is an unknown quantity at this point 
Solved Threads: 0
micah1983 micah1983 is offline Offline
Newbie Poster

back again sorry but need help starting problem

 
0
  #1
Feb 22nd, 2008
A bank charges $10 per month plus the following check fees for a commercial checking account:

$.10 each for less than 20 checks
$.08 each for 20-39 cecks
$.06 each for 40-59 checks
$.04 each for 60 or more checks

The bank also charges an extra $15 if the balance of the account falls below $400 (before any check fees are applied). Write a program that asks for the beginning balance and the number of checks written. Compare and display the bank's service fees for the month.

Input Validation: Do not accept a negative value for the number of checks written. If a negative value is given for the beginning balance, display an urgent message indicating the account is overdrawn.

her is what i have so far, if you don't mind could you tell me the operations i need to figure this out:
  1. #include <iomanip>
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. double begbal, checkw, ppch, banksf;
  8. banksf = 10
  9. cout << "Enter your beginning balance ";
  10. cin >> begbal;
  11. cout << "Enter the number of written checks ";
  12. cin >> checkw
  13.  
  14. if (checkw < 20)
  15. ppch = .10
  16. else if (checkw == 20 || checkw <= 39)
  17. ppch = .08
  18. else if (checkw == 40 || checkw <= 59)
  19. ppch = .06
  20. else if (checkw > 60)
  21. ppch = .04
  22. else
  23. cout << fixed << setprecision(2);
  24.  
  25. return 0;
  26. }
Last edited by Narue; Feb 22nd, 2008 at 1:52 pm. Reason: Added code tags, please do it yourself next time.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,273
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: 378
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: back again sorry but need help starting problem

 
0
  #2
Feb 22nd, 2008
Use a while or a do while condition to neglect negative input.
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 1,679
Reputation: vmanes is a splendid one to behold vmanes is a splendid one to behold vmanes is a splendid one to behold vmanes is a splendid one to behold vmanes is a splendid one to behold vmanes is a splendid one to behold vmanes is a splendid one to behold 
Solved Threads: 193
vmanes's Avatar
vmanes vmanes is offline Offline
Posting Virtuoso

Re: back again sorry but need help starting problem

 
0
  #3
Feb 22nd, 2008
You can save writing, and unnecessary testing in your check charge section:
  1. if (checkw < 20)
  2. ppch = .10
  3. else if (checkw == 20 || checkw <= 39)
  4. ppch = .08
  5. else if (checkw == 40 || checkw <= 59)
  6. ppch = .06
  7. else if (checkw > 60)
  8. ppch = .04
  9. else
  10. cout << fixed << setprecision(2);
lines 3 and 5 don't need to check for equality to the low end, the fact the previous test was false ensures that.
Line 7 can simply be an else - you know the number of checks is 60 or more by the time you get here.
Why do you have the formatting statement as part of this if...else block? It should stand alone.
Revision:
  1. if (checkw < 20)
  2. ppch = .10
  3. else if ( checkw <= 39)
  4. ppch = .08
  5. else if ( checkw <= 59)
  6. ppch = .06
  7. else
  8. ppch = .04
  9.  
  10. cout << fixed << setprecision(2); //should be moved elsewhere in code
From here, you need to test the balance to determine if penalty applies, then deduct fees from balance.

Of course, in between lines 11 and 13 of your original post, you must check for negative balance, display the message required. It's not clear whether you then exit the program, or let the user try again.
Everyone's gotta believe in something. I believe I'll have another drink.
~~~~~~~~~~~~~~~~~~
Looking for an exciting graduate degree? Robotics and Intelligent Autonomous Systems (RIAS) at SDSM&T See the program brochure here.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 5
Reputation: micah1983 is an unknown quantity at this point 
Solved Threads: 0
micah1983 micah1983 is offline Offline
Newbie Poster

i'm sorry people but no understanding something

 
0
  #4
Feb 25th, 2008
  1. //Chpt4prgm11
  2. //Micah Standing
  3.  
  4. #include <iomanip>
  5. #include <iostream>
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. double begbal, checkw, ppch, bankaf, extrabf;
  11. bankaf = 10
  12. extrabf = 15
  13. cout << "Enter your beginning balance ";
  14. cin >> begbal;
  15. cout << "Enter the number of written checks ":
  16. cin << checkw
  17.  
  18.  
  19.  
  20. cout << fixed << setprecision(2);
  21. if (checkw < 20)
  22. ppch = .10
  23. else if ( checkw <=39)
  24. ppch = .08
  25. else if (checkw <=59)
  26. ppch = .06
  27. else
  28. ppch = .04
im not understanding, where does the equations for the negatice balance and what u mean when u say i need to test the balance, then deduct fees and also is the setpercision command in the right place, also does that extrabf thing ok its for the extra $15 if it's below $400.
Last edited by Ancient Dragon; Feb 25th, 2008 at 12:32 am. Reason: add code tags
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,571
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1485
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Still Learning

Re: i'm sorry people but no understanding something

 
0
  #5
Feb 25th, 2008
Why did you start a new thread? You should have just added to your existing thread so that people would know what in the world you are talking about.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 483
Reputation: DangerDev has a spectacular aura about DangerDev has a spectacular aura about 
Solved Threads: 59
DangerDev's Avatar
DangerDev DangerDev is offline Offline
Posting Pro in Training

Re: i'm sorry people but no understanding something

 
0
  #6
Feb 25th, 2008
can you explain your question bit more...
Freedom in the Mind, Faith in the words.. Pride in our Souls...
Indian Developer
http://falaque.wordpress.com/
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 5
Reputation: micah1983 is an unknown quantity at this point 
Solved Threads: 0
micah1983 micah1983 is offline Offline
Newbie Poster

Re: back again sorry but need help starting problem

 
0
  #7
Feb 25th, 2008
all i want to know is what equations i need for this problem and if i got my setprecision in the right place.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 5
Reputation: micah1983 is an unknown quantity at this point 
Solved Threads: 0
micah1983 micah1983 is offline Offline
Newbie Poster

Re: i'm sorry people but no understanding something

 
0
  #8
Feb 25th, 2008
dangerdev beginning balance * checks writting * price per check; is this one of the equations i need for this program, if it is, is there anything else i need to add to it. also where in the program do i put something about the extra $15 if less then $400. also if the setprecision is in the right place on my program.
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 280
Reputation: joshmo is an unknown quantity at this point 
Solved Threads: 19
joshmo joshmo is offline Offline
Posting Whiz in Training

Re: back again sorry but need help starting problem

 
0
  #9
Feb 25th, 2008
use nested if...check first if checkw is less than zero to avoid the negative input...u can modify it to re-request for an input or to quit
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 55
Reputation: carnage is an unknown quantity at this point 
Solved Threads: 2
carnage carnage is offline Offline
Junior Poster in Training

Re: back again sorry but need help starting problem

 
0
  #10
Feb 25th, 2008
don't forget to put semicolons after statements
anyway,

for the additional $15 if balance is < $400

  1. if (begbal<400)
  2. total_bank_fees += 15;

equation for check fees:
  1. total_check_fees = ppch * checkw;

then just add everything
  1. total_bank_fees += total_check_fees;


use do while for the validation of balance
  1. do {
  2. cin>>begbal;
  3. if (begbal<0)
  4. cout<<"Your account is overdrawn.";
  5. }while (begbal<0);

then do the same with checks
Last edited by carnage; Feb 25th, 2008 at 2:12 am.
Reply With Quote Quick reply to this message  
Reply

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



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC