{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

cs31day6 Wk3 M

# cs31day6 Wk3 M - if(conditions stmtT else stmtT...

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

if (conditions) if (condition) stmtT stmtT else stmtT ... double withholdingsRate; cout << "You earned \$" << amtEarned << endl; if (payRate >= 9.00) withholdingRate = 0.10; else withholdingRate = 0.05; cout << "\$" << withholdingRate * amtEarned << " will be withheld." << endl; assignment statement variable = expression; int m = 2; int n = 3; n = 4 * m; // n is now 8 n = 2 * n; // n is now 16 int a = 3; int b = a + 5; // b is now 8 ... a = 4; // b is still 8 b = a + 4; // b is 44 a = 5; // b is still 44 the computer does not keep track of how the variable obtained its value. it just knows that value it currently is assigned to. _________________ #include <iostream> using namespace std; int main() { double HOURLY_RATE_THRESHOLD = 9.00; // make it easier to change these values if they change double HIGH_WITHHOLDING_RATE = 0.10; double LOW_WITHHOLDING_RATE = 0.05;

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

View Full Document
// Gather input data cout << "How many hours did you work? "; double hoursWorked; cin >> hoursWorked; cout << "What is your hourly rate of pay? "; double payRate; cin >> payRate; // Compute earnings and withholdings double amtEarned = hoursWorked * payRate; cout.setf(ios::fixed); cout.precision(2); cout << "You earned \$" << amtEarned << endl; double withholdingRate;
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 6

cs31day6 Wk3 M - if(conditions stmtT else stmtT...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online