Well, I've made a little progress from last week when I worked my first program using "getline" and "strings", but I'm still not good at using mathematics in programs? Any help I can get to push me forward is greatly appreciated.
You are to write a program to compute the amount of a person's water bill. The input to the program will be the customer name (read with getline), the type of customer (a string) and the number of gallons of water used for the month (a double). The customer name will have a variable number of words in the name, so the name needs to be read with getline. The type of customer will be either "R" for residential customers, "B" for business customers, "G" for government or "NP" for non-profit customers.
The charges depend on the customer type.
For residential customers, there is a water base fee of $15 and a charge of $0.02 per gallon for all gallons over 1000 used in a month.
For business customers, there is a water base fee of $25 and a charge of $0.03 per gallon for all gallons over 2000 used in a month.
For non-profit and government customers, there is a water base fee of $5 and a charge of $0.01 per gallon for all gallons over 500 used in a month.
The sewage base fee equals the water base fee for all customers and the sewage usage fee is 80% of the water usage fee for all customers.
Jones County Junior College
Gallons used ................ 100000
Water base fee .............. $ 5.00
Water usage fee ............. $ 995.00
Sewage base fee ............. $ 5.00
Sewage usage fee ............ $ 796.00
Total due ................... $ 1801.00
This is what I have so far.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
#include <iostream>
#include <string>
using namespace std;
int main ()
{
double gallons;
string str;
cout << "Please enter full name: ";
getline (cin,str);
string R;
R = "Residential";
cout << "R is: " << R << endl;
cout<<"Enter Gallons :";
cin>>gallons;
system("pause");
return 0;
}
|