Ok so I've got this homework problem thats killing me. Here's the problem:

A bank account charges $10 per month plus the following check fees for a commercial checking account:
$.10 each for fewer 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 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 overdrawn. This is the source code I got now(I've written like 5 of em)(please don't laugh)

#include <iostream>
using namespace std;


int main()
{
int checks = 0;    
double balance,fee;

    cout << "Hello What's Your Balance? "<<endl;
    cin >> balance;
    



    
    
    
    if (balance <400 && >=0 ) {

    cout << "HOW MANY CHECKS HAVE YOU WRITTEN?";
    cin >> checks;

    if (checks < 0) {
        cout "Can't do that";
    }
    
    
    if (checks < 20 ) {

    fee = .10 * checks + 10 + 15;
    

     cout << " Bank Service charges for the month is "<< fee << " Dollars ";

    }
    else if (checks <=39 && checks >=20){
    fee = .08 * checks + 10 + 15;

    cout << " Bank Service charges for the month is "<< fee << " Dollars ";

        


    }else if (checks <=59 && checks >=40 ){
    fee = .06 * checks + 10 + 15;
    cout << " Bank Service charges for the month is "<< fee << " Dollars ";




    }else if (checks >60 ){

    fee = .04 * checks + 10 + 15;


    cout << " Bank Service charges for the month is "<< fee << " Dollars ";

    }
    
    else {

fee = .10 * checks + 10 + 15;

cout << " Bank Service charges for the month is "<< fee << " Dollars ";
}

    }

    else if ( balance >=400){
        cout << "HOW MANY CHECKS HAVE YOU WRITTEN?";
        cin >> checks;
    
    
        
        if (checks < 20) {

    fee = .10 * checks + 10  ;
    

     cout << " Bank Service charges for the month is "<< fee << " Dollars ";

    }
    else if (checks <=39 && checks >=20){
    fee = .08 * checks + 10 ;

    cout << " Bank Service charges for the month is "<< fee << " Dollars ";

        


    }else if (checks <=59 && checks >=40 ){
    fee = .06 * checks + 10 ;
    cout << " Bank Service charges for the month is "<< fee << " Dollars ";




    }else if (checks >60 ){

    fee = .04 * checks + 10 ;


    cout << " Bank Service charges for the month is "<< fee << " Dollars "<<endl;

    }
    
    else if  {

fee = .10 * checks + 10 ;

cout << " Bank Service charges for the month is "<< fee << " Dollars ";
}
    }
    }

Can a kind soul please help me with this. By, the way this source code has numerous errors in it but I just wanted to show everyone where I was going with it. The thing thats really throwing me off is the input validation part. If that wasn't there, I could do this no problem(lol I think) So can somebody please help me, I really wanna get this program done and get a full grasp of it

Here's your code formatted and with the excess spacing removed. It's much easier to follow:

#include <iostream>
using namespace std;


int main()
{
    int checks = 0;    
    double balance,fee;

    cout << "Hello What's Your Balance? "<<endl;
    cin >> balance;

    if (balance <400 && >=0 ) 
    {
        cout << "HOW MANY CHECKS HAVE YOU WRITTEN?";
        cin >> checks;

        if (checks < 0) 
        {
            cout "Can't do that";
        }

        if (checks < 20 ) 
        {
            fee = .10 * checks + 10 + 15;
            cout << " Bank Service charges for the month is "<< fee << " Dollars ";
        }
        else if (checks <=39 && checks >=20)
        {
            fee = .08 * checks + 10 + 15;
            cout << " Bank Service charges for the month is "<< fee << " Dollars ";
        }
        else if (checks <=59 && checks >=40 )
        {
            fee = .06 * checks + 10 + 15;
            cout << " Bank Service charges for the month is "<< fee << " Dollars ";
        }
        else if (checks >60 )
        {
            fee = .04 * checks + 10 + 15;
            cout << " Bank Service charges for the month is "<< fee << " Dollars ";
        }
        else
        {
            fee = .10 * checks + 10 + 15;
            cout << " Bank Service charges for the month is "<< fee << " Dollars ";
        }
    }
    else if ( balance >=400)
    {
        cout << "HOW MANY CHECKS HAVE YOU WRITTEN?";
        cin >> checks;

        if (checks < 20) 
        {
            fee = .10 * checks + 10  ;
            cout << " Bank Service charges for the month is "<< fee << " Dollars ";
        }
        else if (checks <=39 && checks >=20)
        {
            fee = .08 * checks + 10 ;
            cout << " Bank Service charges for the month is "<< fee << " Dollars ";
        }
        else if (checks <=59 && checks >=40 )
        {
            fee = .06 * checks + 10 ;
            cout << " Bank Service charges for the month is "<< fee << " Dollars ";
        }
        else if (checks >60 )
        {
            fee = .04 * checks + 10 ;
            cout << " Bank Service charges for the month is "<< fee << " Dollars "<<endl;
        }
        else if 
        {
            fee = .10 * checks + 10 ;]
            cout << " Bank Service charges for the month is "<< fee << " Dollars ";
        }
    }
}

Line 13 is illegal.

if (balance <400 && >=0 )

Every comparison has to have something on both sides of the >= sign or <= sign or whatever. Correct syntax is this:

if (balance <400 && balance >=0 )

Line 74 makes no sense. If you have an "else if", you need a condition. Perhaps you mean plain old "else"?

Fix those two lines and hopefully it'll compile. There may be other errors, but those are the two that stick out to me.

@ Nathaniel using a switch statement would be less than ideal in this case because you have a large range of numbers to work with. Even with fall through you would still need to have 60 cases.

@NathanOliver,

I don't see that. There are 4 categories of fees on check so there are 4 cases. I was thinking along the lines of:

double check_fees = 0.0;
char level_checks = ' ';
if (checks < 20) {level_checks = 'a';} 
if (checks => 20 && checks < 40) {level_checks = 'b';} 
if (checks => 40 && checks < 60) {level_checks = 'c';} 

switch (level_checks) {
   case 'a':
      check_fees = 0.10 * checks;
      break;
   case 'b':
      check_fees = 1.90 + 0.08 * (checks - 19);
      break;
   case 'c':
      check_fees = 1.90 + 1.52 + 0.06 * (checks - 39);
      break;
   default:
      check_fees = 1.90 + 1.52 + 1.14 + 0.04 * (checks - 59);
      break;
   }

int low_balance = 0;

if (balance < 400) {low_balance = 1;}
fee = 10.0 + check_fees + 15.0 * low_balance;
cout <<"Bank service charges for the month are $" << fee << " .\n";

Where do you see at least 60 cases?

Doing the way you have done would not require 60 cases but why would you want to do it this way? It seems to me that it adds another layer of complexity. Since you are still using the if statements why not do the calculation in the body of the if statement?

//...
if (checks < 20) {check_fees = 0.10 * checks;} 
else if (checks => 20 && checks < 40) {check_fees = 1.90 + 0.08 * (checks - 19)} 
else if (checks => 40 && checks < 60) {check_fees = 1.90 + 1.52 + 0.06 * (checks - 39);}
else {check_fees = 1.90 + 1.52 + 1.14 + 0.04 * (checks - 59)}
//...

Your last post is better code than mine, Oliver. In any case, both were better than what the OP has. With yours, 8 lines of code does what the OP used 40 lines to do.

Sorry guys I'm really not that experienced with C++ and programming in general, this is my first year in programming classes so I'm still learning.I appreciate everybody's input, I will surely continue to work hard and eventually get to u guys level lol. I just go with what I know, this is the final program though

#include <iostream>
#include <fstream>
using namespace std;


int main()        
{
//Declare Variables and output file
int checks = 0;    
double balance,fee;ofstream outData;
outData.open("Pg.236number12.out");

    //Get Balance from User
    cout << "Hello What's Your Balance? "<<endl;
    cin >> balance;
    //If Balance in the negative then display message that account is overdrawn
    if (balance <=-1)
    {
        cout << "Account is Overdrawn!!! OH NO!!!!"<<endl;
        outData<< "Accout is Overdrawn"<<endl;//Writes to output file
    }
    
    //if not continue to get the number of checks written
    else if (balance <400 && balance>=0 ) {
    //Get number of checks written
    cout << "HOW MANY CHECKS HAVE YOU WRITTEN?"<<endl;
    cin >> checks;
    //If negative value entered for checks display message
    if (checks <= -1) {
        cout << " No Negative Numbers Please!!! "<<endl;
        outData<< "No Negative Numbers Please!!! "<<endl;
    }
    /*If not continue on with fee calculations 
      *note* extra 15 dollars charged for balances under
      $400*/
    
    else if (checks < 20 ) {

    fee = .10 * checks + 10 + 15;
    

     cout << " Bank Service charges for the month is "<< fee << " Dollars "<<endl;
     outData<< "Bank Service Charges for the month is "<< fee << "Dollars";
    }
    else if (checks <=39 && checks >=20){
    fee = .08 * checks + 10 + 15;

    cout << " Bank Service charges for the month is "<< fee << " Dollars "<<endl;
    outData<< " Bank Service charges for the month is " << fee << " Dollars "<<endl;
        


    }else if (checks <=59 && checks >=40 ){
    fee = .06 * checks + 10 + 15;
    cout << " Bank Service charges for the month is "<< fee << " Dollars "<<endl;
    outData << " Bank Service charges for the month is "<< fee << "Dollars "<<endl;



    }else if (checks >60 ){

    fee = .04 * checks + 10 + 15;


    cout << " Bank Service charges for  the month is "<< fee << " Dollars "<<endl;
    outData<< " Bank Service charges for the month is "<< fee << "Dollars "<<endl;


    }
    
    else {

fee = .10 * checks + 10 + 15;

cout << " Bank Service charges for the month is "<< fee << " Dollars "<<endl;
outData<< " Bank Service charges for the month is "<< fee << "Dollars "<<endl;

}

    }

    else if ( balance >=400){
        cout << "HOW MANY  CHECKS HAVE YOU WRITTEN?"<<endl;
        cin >> checks;
    
    if (checks <= -1) {
        cout << " No Negative Numbers Please!!! ";
        outData<< " Bank Service charges for the month is "<< fee << "Dollars "<<endl;

    }
        
        else if (checks < 20 && checks>0) {

    fee = .10 * checks + 10  ;
    

     cout << " Bank Service charges for the month is "<< fee << " Dollars ";
    outData<< " Bank Service charges for the month is "<< fee << "Dollars "<<endl;


    }
    else if (checks <=39 && checks >=20){
    fee = .08 * checks + 10 ;

    cout << " Bank Service charges for the month is "<< fee << " Dollars "<<endl;
    outData<< " Bank Service charges for the month is "<< fee << "Dollars "<<endl;


        


    }else if (checks <=59 && checks >=40 ){
    fee = .06 * checks + 10 ;
    cout << " Bank Service charges for the month is "<< fee << " Dollars ";
    outData<< " Bank Service charges for the month is "<< fee << "Dollars "<<endl;


    }else if (checks >=60 ){

    fee = .04 * checks + 10 ;

    cout << " Bank Service charges for the month is  "<< fee << " Dollars " <<endl;
    outData<< " Bank Service charges for the month is "<< fee << "Dollars " <<endl;

    }
    
    else  {

fee = .10 * checks + 10 ;
{
cout << " Bank Service charges for the month is  "<< fee << " Dollars "<<endl;
outData<< " Bank Service charges for the month is "<< fee << "Dollars "<<endl;

}
    
    }
    }
}
This question has already been answered. Start a new discussion instead.