COMP 110: Introduction to Programming Tyler Johnson Feb 4, 2009 MWF 11:00AM-12:15PM Sitterson 014.

Slides:



Advertisements
Similar presentations
Chapter 4 Loops Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved
Advertisements

COMP 110: Introduction to Programming Tyler Johnson Feb 11, 2009 MWF 11:00AM-12:15PM Sitterson 014.
COMP 110: Introduction to Programming Tyler Johnson Feb 18, 2009 MWF 11:00AM-12:15PM Sitterson 014.
COMP 110: Introduction to Programming Tyler Johnson Feb 25, 2009 MWF 11:00AM-12:15PM Sitterson 014.
COMP 110: Introduction to Programming Tyler Johnson Mar 16, 2009 MWF 11:00AM-12:15PM Sitterson 014.
COMP 110: Introduction to Programming Tyler Johnson Mar 23, 2009 MWF 11:00AM-12:15PM Sitterson 014.
COMP 110: Introduction to Programming Tyler Johnson Apr 20, 2009 MWF 11:00AM-12:15PM Sitterson 014.
COMP 110: Introduction to Programming Tyler Johnson Apr 13, 2009 MWF 11:00AM-12:15PM Sitterson 014.
COMP 110: Introduction to Programming Tyler Johnson January 26, 2009 MWF 11:00AM-12:15PM Sitterson 014.
COMP 110: Introduction to Programming Tyler Johnson Feb 23, 2009 MWF 11:00AM-12:15PM Sitterson 014.
COMP 110: Introduction to Programming Tyler Johnson January 12, 2009 MWF 11:00AM-12:15PM Sitterson 014.
COMP 110: Introduction to Programming Tyler Johnson Mar 25, 2009 MWF 11:00AM-12:15PM Sitterson 014.
COMP 110: Introduction to Programming Tyler Johnson Apr 8, 2009 MWF 11:00AM-12:15PM Sitterson 014.
COMP 110: Introduction to Programming Tyler Johnson Apr 1, 2009 MWF 11:00AM-12:15PM Sitterson 014.
COMP 110: Introduction to Programming Tyler Johnson January 28, 2009 MWF 11:00AM-12:15PM Sitterson 014.
COMP 110: Introduction to Programming
COMP 110: Introduction to Programming Tyler Johnson Mar 2, 2009 MWF 11:00AM-12:15PM Sitterson 014.
COMP 110: Introduction to Programming Tyler Johnson Apr 27, 2009 MWF 11:00AM-12:15PM Sitterson 014.
Tax Year TYPES OF PAYMENTS 1040 PG 2 Line & 68 Federal income tax withheld from W-2s, 1099s Estimated payments & $ applied from prior year.
Perspectives on Academic Integrity Cases and Implications for Fostering Ethical Decision Making Ellen L. Landgraf, PhD., CPA, Associate Professor Loyola.
Student Learning Center Time Management Welcome to the Time Management workshop. While we are waiting to begin, please fill out the blank weekly.
October FUEL PRICE EVALUATION Comparing different fuel costs is a complex issue requiring an in-depth knowledge of fuel properties and characteristics,
1 Cathay Life Insurance Ltd. (Vietnam) 27/11/20091.
Chapter 7 - Iteration. Chapter Goals Program repitiation statements – or loops – with the for, while, and do-while statements Program repitiation statements.
February 12, 2013 COMP Introduction to Programming For Statement and More Loops Haohan Li TR 11:00 – 12:15, SN 011 Spring 2013.
Part 1 Chapter 4 Roundoff and Truncation Errors PowerPoints organized by Dr. Michael R. Gustafson II, Duke University All images copyright © The McGraw-Hill.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 4 Loops.
Chapter 5 Loops Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All rights reserved.
Vault 9 Project Update 9 th September 2009 Paul Pointon – Site Project Delivery Manager LLW Repository Ltd.
30 min Scratch July min intro to Scratch A Quick-and-Dirty approach Leaving lots of exploration for the future. (5 hour lesson plan available)
FINAL EXAMINATION SCHEDULE SPRING 2009 MAY 15 – MAY 22 NOTE: A class that meets at more than one of the times on this final examination schedule will take.
Panel 3D = XML file pointer 08/09/20091 LHCb calorimeter meeting (jean-luc PANAZOL)
K eep I t C onfidential Prepared by: Security Architecture Collaboration Team.
Delivering Preference The Marketing Clinic THE MARKETING CLINIC Success Springs From Understanding The Consumer Fully Understanding Regional Preferences.
L6:CSC © Dr. Basheer M. Nasef Lecture #6 By Dr. Basheer M. Nasef.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 3 Loops.
Roundoff and truncation errors
2009 Spring Errors & Source of Errors SpringBIL108E Errors in Computing Several causes for malfunction in computer systems. –Hardware fails –Critical.
11.4 – Infinite Geometric Series. Sum of an Infinite Geometric Series.
June 10, 2015ICS102: while & do-while1 while and do-while Statements.
REPETITION (loops or iteration) Schneider: Sec. 6.1 & 6.3.
5-1 Flow of Control Recitation-01/25/2008  CS 180  Department of Computer Science  Purdue University.
COMP 110 Loops Tabitha Peck M.S. February 11, 2008 MWF 3-3:50 pm Philips
The Islamic University of Gaza Faculty of Engineering Civil Engineering Department Numerical Analysis ECIV 3306 Chapter 3 Approximations and Errors.
CPSC 111 Introduction to Computation October 15 th, 2009 Based on slides by Eiselt, Carter, Murphy, Pottinger.
COMP 14 Introduction to Programming Miguel A. Otaduy May 18, 2004.
1 CSC 1401 Computer Programming I Hamid Harroud School of Science and Engineering, Akhawayn University
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
COMP 110 Switch Statements and Loops Tabitha Peck M.S. February 6, 2008 MWF 3-3:50 pm Philips
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 6 Repetition Statements.
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Adrian Ilie COMP 14 Introduction to Programming Adrian Ilie June 30, 2005.
New Mexico Computer Science For All More Looping in NetLogo Maureen Psaila-Dombrowski.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. by Lale Yurttas, Texas A&M University Chapter 31.
Real Numbers Week 1 Topic 1. Real Numbers  Irrational Numbers  Numbers that cannot be written as a fraction  √2, π  Rational Numbers  Numbers that.
Introduction to Numerical Analysis I
COMP 110: Introduction to Programming Tyler Johnson Feb 2, 2009 MWF 11:00AM-12:15PM Sitterson 014.
© 2004 Pearson Addison-Wesley. All rights reserved February 17, 2006 The ‘while’ Statement ComS 207: Programming I (in Java) Iowa State University, SPRING.
16. Binary Numbers Programming in C++ Computer Science Dept Va Tech August, 1999 © Barnette ND, McQuain WD, Keenan MA 1 Binary Number System Base.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Chapter 3.
COMP 110 More loops Luv Kohli September 15, 2008 MWF 2-2:50 pm Sitterson
Spring 2006CISC101 - Prof. McLeod1 Announcements Assn 4 is posted. Note that due date is the 12 th (Monday) at 7pm. (Last assignment!) Final Exam on June.
Why Repetition? Read 8 real numbers and compute their average REAL X1, X2, X3, X4, X5, X6, X7, X8 REAL SUM, AVG READ *, X1, X2, X3, X4, X5, X6, X7, X8.
Programming in Java (COP 2250) Lecture 12 & 13 Chengyong Yang Fall, 2005.
1 CSC103: Introduction to Computer and Programming Lecture No 9.
Introduction to Numerical Analysis I
Looping and Repetition
Introduction to Object-Oriented Programming with Java--Wu
Repetition Statements (Loops) - 2
REPETITION Why Repetition?
Presentation transcript:

COMP 110: Introduction to Programming Tyler Johnson Feb 4, 2009 MWF 11:00AM-12:15PM Sitterson 014

COMP 110: Spring Announcements Program 1 due tonight by midnight Lab 2 due tomorrow by midnight Lab 1 has been graded

COMP 110: Spring Questions?

COMP 110: Spring Today in COMP 110 Lab 1 In-Class Exercise Floating-Point Numbers Loops

COMP 110: Spring Floating-Point Numbers Floating-point numbers (double, float) store real numbers in a computer Numbers with some fractional component such as 8.5, 99.9, Floating-point numbers are approximate quantities and are not exact!

COMP 110: Spring Floating-Point Numbers Consider the number 1/3 = Computers have finite storage and cannot store infinitely repeating decimals In a computer, the number 1/3 is stored as , with part of the fraction missing or truncated Since is < 1/3, this representation is inexact

COMP 110: Spring Floating-Point Numbers When using floating-point numbers, small errors will accumulate over time as operations are performed == tests whether two numbers are exactly equal You should never use == or != to compare floating-point numbers

COMP 110: Spring Floating-Point Comparison To compare two floating-point numbers, check if the difference is within some tolerance float a,b; final float EPSILON = 1e-6; //10^-6 … if(Math.abs(a – b) < EPSILON) //Math.abs() is absolute value System.out.println(a and b are the same!); else System.out.println(a and b are different!);

COMP 110: Spring Loops Programs often need to repeat some action For example, when grading a test, the process of grading is repeated for each student

COMP 110: Spring Loops A portion of a program that repeats some action is called a loop The statements that are repeated are called the loop body Each repetition of the loop body is called an iteration

COMP 110: Spring Loops All loops must also have a stopping condition Describes under what condition(s) iteration should cease Example When the process of grading is completed for all students, the instructor will stop grading

COMP 110: Spring Loop Example A loop that counts up to a certain number n Evaluate i <= n ? Execute Print i i = i + 1; Execute End Program Start i = 1 false true Loop Body Stopping Condition

COMP 110: Spring While Statements The while statement can be used to construct a loop in Java while(Boolean_Expression) { Statement_1 Statement_2 … Statement_N } As long as Boolean_Expression is true, the statements in the loop body are executed

COMP 110: Spring While Example A program that counts up to a certain number int number; … //number is set to some value, e.g. user input int count = 1; while(count <= number) { System.out.print(count + ", "); count++; }

COMP 110: Spring While Example int number = 4; int count = 1; while(count <= number) { System.out.print(count + ", "); count++; } IterationcountOutput 111, 221, 2, 331, 2, 3, 441, 2, 3, 4,

COMP 110: Spring Programming Demo How can we extend MenuCalculator.java to allow the user to re-enter input when the input is invalid? Step 1: Ask the user for input Step 2: Check the input Step 3: If the input is invalid, go to Step 1 Step 4: Perform the selected operation

COMP 110: Spring Programming Demo Evaluate Input Valid? Execute Present Menu Read Input Execute Perform User Selection Start true false Loop Body Stopping Condition Allowing the user to re-enter input

COMP 110: Spring Friday Recitation Bring Laptops (fully charged) Textbook