You should start by thinking about the design of the program. What variables will you need? Probably one for type of user (residential or business), one for the residential gallons, another for the business gallons. Then a float variable for the residential rate and business rate.
Then think about getting user input, ask for type of user, then number of gallons.
Most people don't just hand out code on the forums because it's important to help you learn how to do it, but here is something to get you started.
1 2 3 4 5
|
char user; //get the type of user here
double rGallons; //get the number of gallons if residential
double bGallons; //get the number of gallons if business
float residentialRate; //note use of float because it involves decimal answers
float businessRate;
|
The following would be your if statement if 'r' is entered and gallons is under 8000:
1 2 3 4
|
if (rGallons < 8000) {
residentialRate = rGallons * 0.004;
cout << "The water bill is $" << residentialRate << " for " << rGallons << " gallons.";
}
|
For over 8000, think about the math.
Something like this would work:
1 2 3 4 5 6
|
if (rGallons > 8000) {
float rOver = rGallons - 8000;
residentialRate = (8000 * 0.004);
rOver = rOver * 0.007;
cout << "Bill is $" << residentialRate << for first 8000 plus $ << rOver << for the rest.";
}
|
The math will be nearly identical for the business statements. Make sure your output meets the requirements you mentioned above, you may have to play with this a bit because a float variable won't round off penny's so an answer may be something like $34.545 instead of $34.45. This should be plenty of information to help get you started.