Building Java Programs

Slides:



Advertisements
Similar presentations
CS110 Programming Language I
Advertisements

8-May-15 Additional control structures. 2 The if-else statement The if-else statement chooses which of two statements to execute The if-else statement.
Repetition Statements Recitation – 02/20/2009 CS 180 Department of Computer Science, Purdue University.
Copyright © 2012 Pearson Education, Inc. Chapter 6 More Conditionals and Loops Java Software Solutions Foundations of Program Design Seventh Edition John.
Conditions What if?. Flow of Control The order of statement execution is called the flow of control Unless specified otherwise, the order of statement.
Introduction to Computers and Programming Lecture 10: For Loops Professor: Evan Korth New York University.
Introduction to Computers and Programming Lecture 10: For Loops Professor: Evan Korth New York University.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
Building Java Programs
CS 117 Spring 2002 Review for Exam 2 March 6, 2002 open book, 1 page of notes.
Copyright 2008 by Pearson Education 1 Midterm announcements Next week on Friday May 8 Must bring an ID Open book, open notes, closed electronics Must attend.
Conditionals with Strings The comparison operators we’ve seen so far (==, !=, >=, > etc.) all apply to numbers ( ints floats doubles etc.) and return either.
Building Java Programs
If statements Chapter 3. Selection Want to be able to do a statement sometimes, but not others if it is raining, wear a raincoat. Start first with how.
The switch Statement, DecimalFormat, and Introduction to Looping
Chapter 5 Conditionals and Loops. © 2004 Pearson Addison-Wesley. All rights reserved2/33 Conditionals and Loops Now we will examine programming statements.
CIS3931 – Intro to JAVA Lecture Note Set 3 19-May-05.
CSC 1051 M.A. Papalaskari, Villanova University Repetition CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing.
Instructor: Alexander Stoytchev CprE 185: Intro to Problem Solving (using C)
© 2004 Pearson Addison-Wesley. All rights reserved February 20, 2006 ‘do’ and ‘for’ loops ComS 207: Programming I (in Java) Iowa State University, SPRING.
Repetition & Loops. One of the BIG advantages of a computer: ­It can perform tasks over and over again, without getting bored or making mistakes (assuming.
Instructor: Alexander Stoytchev CprE 185: Intro to Problem Solving (using C)
University of Palestine software engineering department Introduction to data structures Control Statements: Part 1 instructor: Tasneem Darwish.
Introduction to Computers and Programming Lecture 14: User defined methods (cont) Professor: Evan Korth New York University.
F27SA1 Software Development 1 3. Java Programming 2 Greg Michaelson.
Copyright © 2012 Pearson Education, Inc. Chapter 6 More Conditionals and Loops Java Software Solutions Foundations of Program Design Seventh Edition John.
CS101 Computer Programming I Chapter 4 Extra Examples.
1 Building Java Programs Chapter 7: Arrays These lecture notes are copyright (C) Marty Stepp and Stuart Reges, They may not be rehosted, sold, or.
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Lucas Bang Lecture 5: Introduction to C: More Control Flow.
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
Introduction to Java Java Translation Program Structure
CS161 Topic #16 1 Today in CS161 Lecture #16 Prepare for the Final Reviewing all Topics this term Variables If Statements Loops (do while, while, for)
1 Building Java Programs Chapter 5 Lecture 5-3: Boolean Logic and Assertions reading: 5.3 – 5.5.
Chapter 2 – Properties of Real Numbers 2.1 – The Real Number Line.
Intro to CIT 594
COMP 110: Spring Announcements Lab 1 was due at noon Lab 2 on Friday (Bring Laptops) Assignment 1 is online TA Office hours online 30-min quiz at.
Chapter 5 Conditionals and Loops. © 2004 Pearson Addison-Wesley. All rights reserved5-2 The switch Statement The switch statement provides another way.
Topics Logical Operators (Chapter 5) Comparing Data (Chapter 5) The conditional operator The switch Statement The for loop Nested Loops.
Flow of Control Unless indicated otherwise, the order of statement execution through a method is linear: one after the other in the order they are written.
Chapter 3 Boolean Expressions Section 3.2 Slides prepared by Rose Williams, Binghamton University Kenrick Mock, University of Alaska Anchorage.
ITI 1120 Lab #3 Tracing and Branching Contributors: G. Arbez, M. Eid, D. Inkpen, A. Williams, D. Amyot.
CSCI 1226 FALL 2015 MIDTERM #1 REVIEWS.  Types of computers:  Personal computers  Embedded systems  Servers  Hardware:  I/O devices: mice, keyboards,
1 CSE 142 Midterm Review Problems These lecture notes are copyright (C) Marty Stepp and Stuart Reges, They may not be rehosted, sold, or modified.
1 Program Development  The creation of software involves four basic activities: establishing the requirements creating a design implementing the code.
Methods OR HOW TO MAKE A BIG PROGRAM SEEM SMALLER.
Shortcoming of the FOR-DO loop When you use the FOR-DO loop you must know how many times you want to perform an action. What if you didn’t know how many.
1 CSE 142 Final Exam Review Problems. 2 Question Types expressions array mystery inheritance mystery file processing array programming Critters classes.
Instructor: Alexander Stoytchev CprE 185: Intro to Problem Solving (using C)
Java Programming: From Problem Analysis to Program Design, 4e Chapter 5 Control Structures II: Repetition.
Instructor: Alexander Stoytchev CprE 185: Intro to Problem Solving (using C)
Copyright 2009 by Pearson Education Building Java Programs Chapter 5 Lecture 5-3: Boolean Logic reading: 5.2 self-check: # exercises: #12 videos:
Programming in Java (COP 2250) Lecture 12 & 13 Chengyong Yang Fall, 2005.
Introduction to Computers and Programming Lecture 10: For Loops Professor: Evan Korth New York University.
© 2004 Pearson Addison-Wesley. All rights reserved October 5, 2007 Arrays ComS 207: Programming I (in Java) Iowa State University, FALL 2007 Instructor:
CMSC201 Computer Science I for Majors Lecture 12 – Midterm Review Prof. Katherine Gibson.
CMSC201 Computer Science I for Majors Lecture 13 – Midterm Review
Yanal Alahmad Java Workshop Yanal Alahmad
CSc 110, Spring 2017 Lecture 14: Boolean Logic and Midterm Review
Selenium WebDriver Web Test Tool Training
CMSC201 Computer Science I for Majors Lecture 13 – Midterm Review
Midterm Review Problems
FINAL EXAM INFORMATION
Building Java Programs
Building Java Programs
Arrays October 6, 2006 ComS 207: Programming I (in Java)
Building Java Programs
Midterm Review October 23, 2006 ComS 207: Programming I (in Java)
Building Java Programs
‘do’ and ‘for’ loops October 1, 2007 ComS 207: Programming I (in Java)
‘do’ and ‘for’ loops October 2, 2006 ComS 207: Programming I (in Java)
Presentation transcript:

Building Java Programs Chapters 1-5 Lecture 13: Midterm Review

Midterm Tips Bring Husky Card, know your section and TA Open book No notes, calculators, phones, digital textbooks (Kindle, etc) 10 point penalty for violating this rule When instructor calls time, close your test Seriously…nothing you write in a few seconds is worth 10 points You must turn in a test to leave the room

Midterm Tips The only acceptable abbreviations S.o.p (System.out.print) S.o.pln (System.out.println) S.o.pf (System.out.printf) A (ALWAYS) N (NEVER) S (SOMETIMES) If you write A, N, or S and we can’t tell what it is, it is wrong

Midterm Tips Test format 5 mechanical questions (60 points total) Expressions Parameter Mystery If/Else Mystery While Mystery Assertions 2 programming questions (15 points each) 1 programming question (10 points) 1 extra credit question (1 point)

Midterm Tips Not covered: Programming Questions Graphics, DrawingPanel, Color, Random Expressions (question 1) resulting in boolean values No writing methods that return boolean values Programming Questions Not graded on style unless specifically mentioned in problem If it works, full credit Method header is worth 1 or 2 points Look for words that suggest different concepts Repetition  loops Conditions  if/else If we tell you not to do something in your solution…don’t do it

isPowerOfTwo Write a static method isPowerOfTwo that takes an integer n as an argument, and that returns true if n is a power of two, and otherwise false. If n is zero or negative, return false. Note that isPowerOfTwo(1) should return true, since 20=1. Practice-It

speedingTicket Practice-It Write a method speedingTicket that decides whether a given driver should be given a speeding ticket from a police officer. The method accepts three parameters: the driver's car speed in miles per hour, as an integer; the current speed limit, as an integer; and whether or not the police officer has eaten a donut today, as a true/false value. (A police officer that has eaten a donut is happy, so he/she is less likely to give the driver a ticket.) Your method should return true if the driver should receive a speeding ticket, and false if not. A driver should be given a speeding ticket if any of the following conditions are met: The officer has eaten a donut (true) and the driver's speed is at least 10 mph over the speeding limit. The officer has not eaten a donut (false) and the driver's speed is at least 5 mph over or under the limit. The driver is going 100 mph or faster, regardless of the speed limit or donut status. You may assume that the integers passed as parameters will be non-negative. Practice-It

firstNotIncluded Write a method called firstNotIncluded that accepts two Strings as parameters. It should return the index of the first character in the second String that is not found in the first String. It should return -1 if all of the characters in the second String are found in the first String. Your method should ignore case. For example, the call firstNotIncluded("aNt", "tan") should return -1 because all of the letters in "tan" can be found in "aNt" if we ignore case. The call firstNotIncluded("section", "tonsils") should return 5 because 'l' is the first character in "tonsils" that cannot be found in "section" and 'l' is at index 5 in "tonsils".