77 964
Assignments Done
98,3%
Successfully Done
In August 2019

# Answer to Question #49836 in C++ for sheikh wahab mahmood

Question #49836
Write a C++ program that displays water bills. The water rates vary depending on the type of usage.
 A code of ‘H’ means home use,
 A code of ‘C’ means commercial use,
 A code of ‘I’ means industrial use.
Any other code value should be treated as an INVALID INPUT.
Water rates are computed as follows:
Code H: First 1 hundred gallons for \$5.00 and \$0.005 for each additional gallon used
Code C: First 4 hundred gallons for\$1000.00 and \$0.025 for each additional gallon used
Code I: First 4 hundred gallons for \$1500 and \$0.125 for each additional gallon used
Your program should prompt the user to enter:
 An integer account number
 A code in character
 A real number representing the gallons of water consumed.
The output from your program should include the
 Account number
 Message indicating the type of usage,
 Amount of money due from the user
Expert's answer
#include <iostream>

using namespace std;
int main() {
int id; // account number
char code; // code in character
float amount; // the gallons of water consumed
float due; // amount of money due from the user
// Input
cout << "Account number: ";
cin >> id;
cout << "Code in character: ";
cin >> code;
cout << "The gallons of water consumed: ";
cin >> amount;
if (code == 'H') {
// Home use
if (amount < 100) {
due = 5;
} else {
due = 5 + (amount - 100) * 0.005;
}
} else if (code == 'C') {
// Commercial use
if (amount < 400) {
due = 1000;
} else {
due = 1000 + (amount - 400) * 0.025;
}
} else if (code == 'I') {
// Industrial use
if (amount < 400) {
due = 1500;
} else {
due = 1500 + (amount - 400) * 0.125;
}
}
else {
cout << "Invalid input!" << endl;
return 0;
}
// Output
if (code == 'H') {
cout << id << " home use \$" << due;
} else if (code == 'C') {
cout << id << " commercial use \$" << due;
} else if (code == 'I') {
cout << id << " industrial use \$" << due;
}
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

#### Comments

No comments. Be first!

Submit