Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- float home (float g) // home function
- {
- float cost;
- cost = 5+(0.0005 * g);
- return (cost);
- }
- float com (float g) // commercial function
- {
- float cost;
- if (g < 4000000)
- {
- cost = 1000;
- }
- else
- {
- cost = 1000 + (0.00025 * (g - 4000000));
- }
- return (cost);
- }
- float ind (float g) //industrial function
- {
- float cost;
- if (g < 4000000)
- {
- cost = 1000;
- }
- else if (g > 4000000 && g < 10000000)
- {
- cost = 2000;
- }
- else
- {
- cost = 3000;
- }
- return (cost);
- }
- int main()
- {
- int account;
- char type = 0;
- float g, cost;
- cout << "Please input your account number: \n";
- cin >> account;
- cout << "Please enter your usage in gallons.\n";
- cin >> g;
- cout << "Now please enter your account type.\nType h for home, c for commercial, or i for industrial.\nThanks!\n";
- do {
- cin >> type;
- if (type == 'h'){ break; }
- if (type == 'c'){ break; }
- if (type == 'i'){ break; }
- } while (type == 0);
- if (type == 'h')
- {
- cost = home (g);
- }
- else if(type == 'c')
- {
- cost = com (g);
- }
- else
- {
- cost = ind (g);
- }
- cout << "Hi " << account << ", your fee is: $" << cost << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement