View Single Post
  #8 (permalink)  
Old November 7th, 2005, 09:08 AM
Paramesh Paramesh is offline
Authorized User
 
Join Date: Nov 2005
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Paramesh
Default

Now, the link is no longer available.
I'll post the code here for others to take a look at it.
Code:
#include <iostream>

using namespace std;

const double HOUSEPGAL = 0.0005;
const double HOUSEINIT = 5.00;
const double FOURMIL = 4000000;
const double COMINIT = 1000.00;
const double COMADDGAL = 0.00025;

int getBill (char);

int main()
{
        char x;
        double g;
        double result;

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


        switch(getBill (x))
        {

                case 0: result = (g*HOUSEPGAL)+HOUSEINIT;
                        cout << "The amount for your Home water bill is "
                        << result << ". Thank you for your business.";
                                break;
                case 1: if (g<FOURMIL)
                        {
                        result = COMINIT;
                        }
                        else if (g>FOURMIL)
                        {
                        result = (g-FOURMIL)*COMADDGAL+(g*COMINIT);
                        }
                        cout << "The amount for your Corporate bill is "
                                << result << ". Thank you for your business.";
                                break;
                case 2: cout << "Error. Please ask for assistance.";
                                break;
        }

        getchar();
        getchar();
        return 0;
}

int getBill (char x)
{
        if(x == 'c' || x == 'C')
          return 0;
        else if (x == 'h' || x == 'H')
          return 1;
        else
          return 2;
}
and middledd,
There is no line in this code as you said.

Regards,
Paramesh.

"Don't walk behind me; I may not lead.
 Don't walk in front of me; I may not follow.
 Just walk beside me and be my friend."
Reply With Quote