| | |
back again sorry but need help starting problem
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Feb 2008
Posts: 5
Reputation:
Solved Threads: 0
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:
$.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:
C++ Syntax (Toggle Plain Text)
#include <iomanip> #include <iostream> using namespace std; int main() { double begbal, checkw, ppch, banksf; banksf = 10 cout << "Enter your beginning balance "; cin >> begbal; cout << "Enter the number of written checks "; cin >> checkw if (checkw < 20) ppch = .10 else if (checkw == 20 || checkw <= 39) ppch = .08 else if (checkw == 40 || checkw <= 59) ppch = .06 else if (checkw > 60) ppch = .04 else cout << fixed << setprecision(2); return 0; }
Last edited by Narue; Feb 22nd, 2008 at 1:52 pm. Reason: Added code tags, please do it yourself next time.
You can save writing, and unnecessary testing in your check charge section:
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:
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.
c++ Syntax (Toggle Plain Text)
if (checkw < 20) ppch = .10 else if (checkw == 20 || checkw <= 39) ppch = .08 else if (checkw == 40 || checkw <= 59) ppch = .06 else if (checkw > 60) ppch = .04 else cout << fixed << setprecision(2);
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:
C++ Syntax (Toggle Plain Text)
if (checkw < 20) ppch = .10 else if ( checkw <= 39) ppch = .08 else if ( checkw <= 59) ppch = .06 else ppch = .04 cout << fixed << setprecision(2); //should be moved elsewhere in code
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.
~~~~~~~~~~~~~~~~~~
Looking for an exciting graduate degree? Robotics and Intelligent Autonomous Systems (RIAS) at SDSM&T See the program brochure here.
•
•
Join Date: Feb 2008
Posts: 5
Reputation:
Solved Threads: 0
C++ Syntax (Toggle Plain Text)
//Chpt4prgm11 //Micah Standing #include <iomanip> #include <iostream> using namespace std; int main() { double begbal, checkw, ppch, bankaf, extrabf; bankaf = 10 extrabf = 15 cout << "Enter your beginning balance "; cin >> begbal; cout << "Enter the number of written checks ": cin << checkw cout << fixed << setprecision(2); if (checkw < 20) ppch = .10 else if ( checkw <=39) ppch = .08 else if (checkw <=59) ppch = .06 else ppch = .04
Last edited by Ancient Dragon; Feb 25th, 2008 at 12:32 am. Reason: add code tags
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/
Indian Developer
http://falaque.wordpress.com/
•
•
Join Date: Feb 2008
Posts: 5
Reputation:
Solved Threads: 0
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.
•
•
Join Date: Jan 2008
Posts: 55
Reputation:
Solved Threads: 2
don't forget to put semicolons after statements
anyway,
for the additional $15 if balance is < $400
equation for check fees:
then just add everything
use do while for the validation of balance
then do the same with checks
anyway,
for the additional $15 if balance is < $400
c++ Syntax (Toggle Plain Text)
if (begbal<400) total_bank_fees += 15;
equation for check fees:
c++ Syntax (Toggle Plain Text)
total_check_fees = ppch * checkw;
then just add everything
c++ Syntax (Toggle Plain Text)
total_bank_fees += total_check_fees;
use do while for the validation of balance
c++ Syntax (Toggle Plain Text)
do { cin>>begbal; if (begbal<0) cout<<"Your account is overdrawn."; }while (begbal<0);
then do the same with checks
Last edited by carnage; Feb 25th, 2008 at 2:12 am.
![]() |
Similar Threads
- HP Pavilion ze5155 BIOS problem... (Troubleshooting Dead Machines)
- Computer not starting up if hard booting (Motherboards, CPUs and RAM)
- Problem booting into windows xp (Troubleshooting Dead Machines)
- "Windows is starting up..." endlessly... pls help (Windows NT / 2000 / XP)
- Startup problem ASUS board (Motherboards, CPUs and RAM)
- Can't remove "about:blank" homepage. Please help. (Viruses, Spyware and other Nasties)
- Missing "bridge.dll" when starting windows xp home (Viruses, Spyware and other Nasties)
- hardware/re-boot problem... (Windows NT / 2000 / XP)
- Win 2K Pro Log in problem (Windows NT / 2000 / XP)
Other Threads in the C++ Forum
- Previous Thread: Creating an exe file
- Next Thread: Count.cpp
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays assignment based beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete deploy developer dll dynamiccharacterarray email encryption error file format forms fstream function functions game generator getline givemetehcodez graph iamthwee ifstream image input int java lib list loop looping loops map math matrix memory multidimensional multiple newbie news node number numbertoword output pointer problem program programming project python random read recursion recursive reference rpg simple sorting string strings template templates text tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






