I have most of my code written but I need some help with a part of it, I need to get in one more variable and not positive how to go about it.
I need to enter I as a variable for Industrial use: $1000.00 is usage does not exceed 4 million gallons;$2000.00 if usage exceeds 4 million gallons but does not exceed 10 million gallons; and $3000.00 if usage exceeds 10 million gallons.
This is what I have so far.

#include <iostream> // to read cin, cout
#include "conio.h"
#include <iomanip>

using namespace std;

// CONSTANTS

const double HOUSEPGAL = 0.0005; //Constant for price per gallon on house
const double HOUSEINIT = 5.00; //house initial price
const double FOURMIL = 4000000; //Commercial amount for 1000
const double COMINIT = 1000.00; //Commercial initial price for water
const double COMADDGAL = 0.00025; //Commercial price for additional gallon

int getBill (char);

//main

int main()
{
    //variables
        char x;
        double Gal;
        double result = 0;

            cout << fixed << showpoint;

            cout << "Enter bill type (H = home, C = commercial): ";
            cin >> x;
            cout << "Enter gallons of water used: ";
            cin >> Gal;
            cout << endl;


        switch(getBill (x))
        {
                //case 0 is for the House Bill
                case '0': result = (Gal * HOUSEPGAL)+ HOUSEINIT;
                        cout << "**** WATER BILL ****";
                        cout << endl;
                        cout << "Account Type: Home";
                        cout << endl;
                        cout << setprecision(1);
                        cout << "Total Amount Owed: " << result << endl;     
                        cout << "  Thank you for your business.";
                        cout << endl;
                        cout << "********************";
                                break;
                //case 1 is for the Commercial Bill
                case '1': if (Gal < FOURMIL)
                        {
                        result = COMINIT;
                        }
                        else if (Gal > FOURMIL)
                        {
                        result = (Gal - FOURMIL)* COMADDGAL + (Gal * COMINIT);
                        }
                        cout << "**** WATER BILL ****";
                        cout << endl;
                        cout << "Account Type: Commercial";
                        cout << endl;
                        cout << setprecision(1);
                        cout << "Total Amount Owed: " << result;
                        cout << endl;     
                        cout << "Thank you for your business.";
                        cout << endl;
                        cout << "********************";
                                break;
                //case 2 is for the error part
                case '2': cout << "Error. Please ask for assistance.";
                                break;
        }

        return 0;
}

//how the program chooses which case to go with based on the character input
int getBill (char x)
{
        if(x == 'c' || x == 'C')
                return '1';
        else if (x == 'h' || x == 'H')
                return '0';
        else
                return '2';
}

You need to form the range in your if-else statements.

if (Gal <= 4000000) {  // better use less than or equal to & also number is a number
  ...
}
else if (Gal>4000000 && Gal<=10000000) {  // 2nd range
  ...
}
else {  // anything exceeding 10 mil
  ...
}

Then whatever you do inside is to follow the requirement.

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.