cs31day6 Wk3 M

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

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

View Full Document Right Arrow Icon
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;
Background image of page 1

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

View Full DocumentRight Arrow Icon
// 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;
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.

This note was uploaded on 02/02/2011 for the course CS 31 taught by Professor Melkanoff during the Spring '00 term at UCLA.

Page1 / 6

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

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online