{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

June 24 - 6 If(age< 21{cout<< “You’re too young...

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

View Full Document Right Arrow Icon
Reading Ch.3 on “Flow Control” 1. Today a. Commenting i. // declare variable ii. have a header that says who you are and says what the program does iii. break the program into parts. Into paragraphs. 1. Declare variables 2. Get input 3. Do calculations 4. Do output iv. Explain an ambiguous variable value v. Explain unusual code and algorithms you use and places where you do error checking 1. Double num; 2. Get some input from user 3. If (num <0) { alert user that number is below zero} {assume 0 value – assume some sensible value – ask the user to input again} 4. If (x > 0) if (x < 0) 5. If (age < 21) {cout << “You are not old enough to drink in the USA”; x= 21- age; cout << “You still have <<x << years before you can legally drink”;}
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
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 6. If (age < 21) {cout << “You’re too young to drink”; if (age < 12) { cout << “Why are you even asking about this?”;} else {cout << “Just wait a few years!”;} b. Use of “const” i. Variable value is not allowed to be changed once you set it. ii. Const double PI (all caps) = 3.14; c. Error checking d. Practice with branching e. Intro to hw #2 f. Q about hw #1 2. Subject: HW1, Jefri Vanegas a. Int main () i. { ii. double x= 3.14159; iii. int x=2; iv. if (x==2){ v. Cout << setprecision (3) << x << endl; vi. } vii.cout << x << endl; viii. return (0); ix. } Hw #2: Choose your own Adventure Branching Discussion 1. Income tax 8.25 2. (335.5)* (10825) dimes = cents /10; cents= cents %10;...
View Full Document

{[ snackBarMessage ]}

Page1 / 2

June 24 - 6 If(age< 21{cout<< “You’re too young...

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

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