Answer to Question #15430 in C++ for Simon
• 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.
using namespace std;
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 >
bill = 2000;
else if (code == 'i' && gallons >= 10000000)
bill = 3000;
cout << "The bill for account number: " << account << ", will be: $" << bill
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!
You're welcome. We are glad to be helpful.
If you liked our service please press like-button beside answer field. Thank you!
thank you, kind sir