calculating monthly bank fees

This is a discussion on calculating monthly bank fees within the C++ Programming forums, part of the General Programming Boards category; hi everyone! i almost have my program finished (pretty surprised i actually do lol) but i'm having a couple problems. ...

  1. #1
    Registered User helloalyssa's Avatar
    Join Date
    Sep 2010
    Posts
    25

    calculating monthly bank fees

    hi everyone! i almost have my program finished (pretty surprised i actually do lol) but i'm having a couple problems. this is what the program should do (copied straight out of the textbook)

    a bank charges $10 per month plus the following check fees for a commercial checking account:

    $.10 for less than 20 checks
    $.08 each for 20-39 checks
    $.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 the beginning balance and the number of checks written. compute 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 over drawn.


    i'm having a problem with adding the initial $15 if the balance is under $400 and displaying the message if the balance is negative.

    here is the code i have for this part of the program:
    Code:
     // Calculate bank fees based on amount of checks user inputs. 
    
      // if (balance <= 400)
    
      //   fee = 15 + (
    
      if (checks < 20)
    
         fee = checks * .10;
    
      else if (checks < 39)
    
         fee = checks * .08;
    
      else if (checks < 59)
    
         fee = checks * .06;
    
      else if (checks >= 60)
    
         fee = checks * .04;
    
      else if (checks <= 0) 
    
      {
    
         cout << "Your account is overdrawn! \n";
    
         cout << "Number of checks must be zero or more. \n";
    
      }

    the first three lines are commented out because i know they're wrong from trying to run the program. could anyone help me out by giving me some possible suggestions?? thank you

  2. #2
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,604
    So you've got the condition semi-right (it should be below 400, the text says):

    // if (balance <= 400)

    Now, all you need to do is add 15 to the fee. That's what it says. Considering you've managed to calculate the fee from the checks, this should be trivial. What are you having problems with?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User helloalyssa's Avatar
    Join Date
    Sep 2010
    Posts
    25
    do i have add 15 to the fee to the line below // if (balance <= 400) or else if (checks <= 0)?? i'm sorry if this is a dumb question but it's these little problems that really confuse me.

  4. #4
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,604
    Well, you wrote the code, so you must know for what reason you added the two if statements, right?
    If you think this through: imagine placing that under the first if statement, then run a simulation in your mind. Say balance is < 400 and you a number of checks, say, 10. What will happen? Then do the same when it's under the last if statement.

    Which one makes sense?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. monthly payment from math to C++
    By summerwine in forum C++ Programming
    Replies: 4
    Last Post: 06-10-2010, 05:31 PM
  2. Bank Account Problem
    By JayBlay77 in forum C++ Programming
    Replies: 1
    Last Post: 03-19-2009, 08:41 AM
  3. calculating mortgage!!!
    By beho86 in forum C Programming
    Replies: 15
    Last Post: 10-22-2008, 07:28 PM
  4. Recursion
    By Lionmane in forum C Programming
    Replies: 11
    Last Post: 06-04-2005, 12:00 AM
  5. My graphics library
    By stupid_mutt in forum C Programming
    Replies: 3
    Last Post: 11-26-2001, 05:05 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21