include <iostream>
include <iomanip>
include <string>

using namespace std;

// Constants
const float RESLINEFEE = 22.42;
const float RESperGALLONfirst10000 = 2.42;
const float RESperGALLONnext13000 = 3.22;
const float RESperGALLONover23000 = 4.03;
const float COMLINEFEE = 22.09;
const float COMperGALLON = 2.65;
const float INDLINEFEE = 18.41;
const float INDperGALLONfirst200000 = 2.16;
const float INDperGALLONnext2500000 = 1.73;
const float INDperGALLONover2700000 = 4.03;

int menu();

 // Local Identifiers
    string AccountName, Residential, Commercial, Industrial;
    int AccountNumber;
    float Gallons, AmountDue;
    char choice, again;

// main
int main()
{


    do
    {
        system("CLS");
        cout<<"\t\tWelcome to the Cherry Hills Bill Calculator\n";
        cout<<endl;
        cout<<endl;
        cout<<"Please enter the account name:\t";
        cin>>AccountName;
        cout<<"Please enter your 5 digit account number:\t";
        cin>>AccountNumber;
        cout<<"Please enter the number of gallons used this quarter:\t";
        cin>>Gallons;




        switch ( menu())
        {
            case 1: // Residential
                if (Gallons <= 10000)
                    AmountDue=RESLINEFEE+(RESperGALLONfirst10000*Gallons);
                else
                    if ((Gallons > 10000) && (Gallons <= 23000))
                     AmountDue=RESLINEFEE+(RESperGALLONnext13000*Gallons);
                    else
                        if (Gallons > 23000)
                       AmountDue=RESLINEFEE+(RESperGALLONover23000*Gallons);
                       break;

            case 2: // Commercial
                AmountDue=COMLINEFEE+(COMperGALLON*Gallons);
                break;

            case 3: // Industrial
                if (Gallons <= 200000)
                    AmountDue=INDLINEFEE+(INDperGALLONfirst200000*Gallons);
                else
                    if ((Gallons > 200000) && (Gallons <= 2700000))
                     AmountDue=INDLINEFEE+(INDperGALLONnext2500000*Gallons);
                else
                    if (Gallons > 2700000)
                     AmountDue=INDLINEFEE+(INDperGALLONover2700000*Gallons);



        }

        cout<<"Account Name: "<<AccountName<<endl;
        cout<<"Account Number: "<<AccountNumber<<endl;
        cout<<"Gallons Used: "<<Gallons<<endl;
        cout<<"Amount Due: "<< "$" << AmountDue<<endl;
        cout<<fixed<<showpoint<<setprecision(2);
        cout<<"Do you have another account to process? <Y or N>\t";
        cin>>again;
    } while ((again!='N') && (again!='n'));



}

// menu function
int menu()
{
    char choice;
    int ok;
    do
    {
        ok=1;
        cout<<"Please choose from the following account types:\n";
        cout<<"\n";
        cout<<setw(18)<<"H"<<" for residential\n\n";
        cout<<setw(18)<<"C"<<" for commercial\n\n";
        cout<<setw(18)<<"I"<<" for industrial\n\n";
        cin>>choice;



        if (( choice != 'H')&& ( choice != 'C') && ( choice != 'I'))



        {

            cout<<"Invalid choice. Please select again.\n";
            ok=0;
            system("PAUSE");
            system("CLS");

        }
    }while(!ok);
    return choice;
} // end menu function

menu() is supposed to return an int, but it currently returns choice which is a char.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.