{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

proj 2 soln.cpp

proj 2 soln.cpp - Water bill calculator#include...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
// Water bill calculator #include <iostream> #include <string> using namespace std; int main() { // Get and validate inital meter reading cout << "Initial meter reading: "; int initial; cin >> initial; cin.ignore(1000000, '\n'); if (initial < 0) { cout << "---\nThe initial meter reading must be nonnegative." << endl; return 1; } // Get and validate final meter reading cout << "Final meter reading: "; int final; cin >> final; cin.ignore(1000000, '\n'); if (final < initial) { cout << "---\nThe final reading must be at least as large as the initial reading." << endl; return 1; } // Get and validate customer name cout << "Customer name: "; string customer; getline(cin, customer); if (customer == "") { cout << "---\nYou must enter a customer name." << endl; return 1; } // Get and validate month cout << "Month number (1=Jan, 2=Feb, etc.): "; int month; cin >> month; cin.ignore(1000000, '\n'); if (month < 1 || month > 12) { cout << "---\nThe month number must be in the range 1 through 12." << endl; return 1; } // Bill thresholds and rates
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
const int HIGH_TIER1_THRESHOLD = 46; const int LOW_TIER1_THRESHOLD = 32; const double TIER1_RATE = 2.65; const double HIGH_TIER2_RATE = 3.36; const double LOW_TIER2_RATE = 2.79;
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}