lec-10-14

lec-10-14 - 1 ECS10 10/14 Midterm 1 Midterm is Friday Oct...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1 ECS10 10/14 Midterm 1 Midterm is Friday Oct 16, in class. Bring a Scantron 2000 form 10-12 multiple choice questions 65 pts ? Short (8 lines?) program 35 pts? Open book, open notes. Please contact me beforehand if you have to miss it; only illness counts as a reason. Wds Oct 21 is the drop deadline. Programming Problem Approach First understand what the program is supposed to do. Here, the program is supposed to 1 Get user input initial mass, rate of decay 1. Get user input initial mass, rate of decay 2. Reduce mass by (rate of decay) percent 3. Unitl mass is reduced to < 1% of its initial mass Heart of the program will be a while loop. Start in the middleon scratch paper. While loop The program will require a while loop. You The program will require a while loop. You really have to understand how it works. really have to understand how it works. while Boolean is True: do block while while the Boolean the Boolean test is True, the block under test is True, the block under the while statement repeats. the while statement repeats. Somehow the code in the block has to Somehow the code in the block has to eventually make the Boolean False. eventually make the Boolean False. Step 1: Choose variables initialMass - The mass the user inputs at the beginning. Float. mass The mass that decreases every year. Float. rate The percent decay every year. Float. year The number of years so far. Integer. 2 Step 2: Block under the while while _________ : mass = mass - mass*rate/100.0 year = year + 1 print After year year print After year ,year, print The mass is, mass What should the Boolean condition in the while statement be?...
View Full Document

This note was uploaded on 01/14/2010 for the course ECS 10 taught by Professor Amenta during the Spring '07 term at UC Davis.

Page1 / 6

lec-10-14 - 1 ECS10 10/14 Midterm 1 Midterm is Friday Oct...

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