60 414
Assignments Done
98,2%
Successfully Done
In April 2018

Answer to Question #15430 in C++ for Simon

Question #15430

Write a C program that will calculate and print out the bills for the city water company. The water rates vary, depending on whether the bill is for home use, commercial use, or industrial use. A code of h means home use, a code of c means commercial use, and a code of i means industrial use
• Code h: RM5.00 plus RM0.0005 per gallon used
• Code c: RM1000.00 for the first 4 million gallons used and RM0.00025 for each additional gallon
• Code i: RM1000.00 if usage does not exceed 4 million gallons; RM2000.00 if usage is more than 4 million gallons but does not exceed 10 million gallons; and RM3000.00 if usage exceeds 10 million gallons

Your program should prompt the user to enter an account number (type int), the code (type char) and the gallons of water used (type double). Your program should echo the input data and print the amount due from the user.
Expert's answer
#include <iostream>
#include <cmath>
#include <conio.h>
using namespace std;

int main()
{
int account;
char code;
double gallons, bill;

cout << "Enter your account number:" << endl;
cin >> account;

cout << "Now enter your code(h,c, or i):" << endl;
cin >> code;

cout << "Now enter the amount of gallons of water used:" << endl;
cin >> gallons;

if (code == 'h')
{
bill = 5 + (gallons * 0.0005);
}
if (code == 'c' && gallons > 4000000)
{
bill = 1000 + ((gallons - 4000000) * 0.00025);
}
else if (code == 'c' && gallons <= 4000000)
{
bill = 1000;
}
if (code == 'i' && gallons <= 4000000)
{
bill = 1000;
}
else if (code == 'i' && gallons < 4000000 && gallons >
10000000)
{
bill = 2000;
}
else if (code == 'i' && gallons >= 10000000)
{
bill = 3000;
}

cout << "The bill for account number: " << account << ", will be: $" << bill
<< endl;
getch();
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

Assignment Expert
29.10.14, 11:04

Dear Guy,
You're welcome. We are glad to be helpful. 
If you liked our service please press like-button beside answer field. Thank you!

Guy
29.10.14, 01:00

thank you, kind sir

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions