title: mar 2310:49 am (1 of 15)cisweb.bristolcc.edu/.../cis120/c120mar2317.pdf · introduction to...

15
Title: Mar 2310:49 AM (1 of 15)

Upload: others

Post on 02-Oct-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Title: Mar 2310:49 AM (1 of 15)cisweb.bristolcc.edu/.../CIS120/c120Mar2317.pdf · Introduction to CIS120[17 Syll abus Site Resources: Notes and Handouts Examples Program s Presentations

Title: Mar 23­10:49 AM (1 of 15)

Page 2: Title: Mar 2310:49 AM (1 of 15)cisweb.bristolcc.edu/.../CIS120/c120Mar2317.pdf · Introduction to CIS120[17 Syll abus Site Resources: Notes and Handouts Examples Program s Presentations

Three things you need to code to make aneffective loop:

Would be best to define ans as a var but since I did not when I add ct to ct and assign it to ans, the browser figures out I need a var ans and makes it for me.

Title: Mar 23­11:08 AM (2 of 15)

Page 3: Title: Mar 2310:49 AM (1 of 15)cisweb.bristolcc.edu/.../CIS120/c120Mar2317.pdf · Introduction to CIS120[17 Syll abus Site Resources: Notes and Handouts Examples Program s Presentations

Title: Mar 23­11:20 AM (3 of 15)

Page 4: Title: Mar 2310:49 AM (1 of 15)cisweb.bristolcc.edu/.../CIS120/c120Mar2317.pdf · Introduction to CIS120[17 Syll abus Site Resources: Notes and Handouts Examples Program s Presentations

Title: Mar 23­11:26 AM (4 of 15)

Page 5: Title: Mar 2310:49 AM (1 of 15)cisweb.bristolcc.edu/.../CIS120/c120Mar2317.pdf · Introduction to CIS120[17 Syll abus Site Resources: Notes and Handouts Examples Program s Presentations

Remember with the do...while the check of thecontrol is at the bottom. When the check is atthe bottom, the loop gets executed once beforethe check.

Title: Mar 23­11:30 AM (5 of 15)

Page 6: Title: Mar 2310:49 AM (1 of 15)cisweb.bristolcc.edu/.../CIS120/c120Mar2317.pdf · Introduction to CIS120[17 Syll abus Site Resources: Notes and Handouts Examples Program s Presentations

This works the same as the while that wewent through.

Title: Mar 23­11:31 AM (6 of 15)

Page 7: Title: Mar 2310:49 AM (1 of 15)cisweb.bristolcc.edu/.../CIS120/c120Mar2317.pdf · Introduction to CIS120[17 Syll abus Site Resources: Notes and Handouts Examples Program s Presentations

Note the definition ofvar i is not needed since it is done in thefor loop.

Title: Mar 23­11:33 AM (7 of 15)

Page 8: Title: Mar 2310:49 AM (1 of 15)cisweb.bristolcc.edu/.../CIS120/c120Mar2317.pdf · Introduction to CIS120[17 Syll abus Site Resources: Notes and Handouts Examples Program s Presentations

Title: Mar 23­11:34 AM (8 of 15)

Page 9: Title: Mar 2310:49 AM (1 of 15)cisweb.bristolcc.edu/.../CIS120/c120Mar2317.pdf · Introduction to CIS120[17 Syll abus Site Resources: Notes and Handouts Examples Program s Presentations

Title: Mar 23­11:37 AM (9 of 15)

Page 10: Title: Mar 2310:49 AM (1 of 15)cisweb.bristolcc.edu/.../CIS120/c120Mar2317.pdf · Introduction to CIS120[17 Syll abus Site Resources: Notes and Handouts Examples Program s Presentations

Title: Mar 23­11:43 AM (10 of 15)

Page 11: Title: Mar 2310:49 AM (1 of 15)cisweb.bristolcc.edu/.../CIS120/c120Mar2317.pdf · Introduction to CIS120[17 Syll abus Site Resources: Notes and Handouts Examples Program s Presentations

Title: Mar 23­11:48 AM (11 of 15)

Page 12: Title: Mar 2310:49 AM (1 of 15)cisweb.bristolcc.edu/.../CIS120/c120Mar2317.pdf · Introduction to CIS120[17 Syll abus Site Resources: Notes and Handouts Examples Program s Presentations

Title: Mar 23­11:50 AM (12 of 15)

Page 13: Title: Mar 2310:49 AM (1 of 15)cisweb.bristolcc.edu/.../CIS120/c120Mar2317.pdf · Introduction to CIS120[17 Syll abus Site Resources: Notes and Handouts Examples Program s Presentations

Note that I need the promptbetween the while checks.

Title: Mar 23­11:57 AM (13 of 15)

Page 14: Title: Mar 2310:49 AM (1 of 15)cisweb.bristolcc.edu/.../CIS120/c120Mar2317.pdf · Introduction to CIS120[17 Syll abus Site Resources: Notes and Handouts Examples Program s Presentations

Homework ­ check for assignment

Title: Mar 23­11:58 AM (14 of 15)

Page 15: Title: Mar 2310:49 AM (1 of 15)cisweb.bristolcc.edu/.../CIS120/c120Mar2317.pdf · Introduction to CIS120[17 Syll abus Site Resources: Notes and Handouts Examples Program s Presentations

To approaches ­ one thatassumes the user willonly enter 1,2 or 3 andone that checks forentering something else

Title: Mar 23­12:09 PM (15 of 15)