COMP 14: Midterm Review June 8, 2000 Nick Vallidis.

Slides:



Advertisements
Similar presentations
AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to.
Advertisements

Control Structures. Decision Making Structures The if and if…else are all selection control structures that introduce decision-making ability into a program.
CSCI 51 Introduction to Programming Dr. Joshua Stough February 10, 2009.
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.
COMP 14 Introduction to Programming Miguel A. Otaduy May 19, 2004.
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Adrian Ilie COMP 14 Introduction to Programming Adrian Ilie July 5, 2005.
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Adrian Ilie COMP 14 Introduction to Programming Adrian Ilie July 6, 2005.
16-Jun-15 Additional control structures. 2 The if-else statement The if-else statement chooses which of two statements to execute The if-else statement.
Copyright 2008 by Pearson Education 1 Building Java Programs Chapter 2 Lecture 2-2: The for Loop reading: 2.3 self-check: exercises: 2-14 videos:
CS150 Introduction to Computer Science 1
CS 106 Introduction to Computer Science I 02 / 12 / 2007 Instructor: Michael Eckmann.
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.
COMP 14: Looping (part 2) May 31, 2000 Nick Vallidis.
COMP 14 Introduction to Programming Mr. Joshua Stough February 28, 2005 Monday/Wednesday 11:00-12:15 Peabody Hall 218.
ECE122 L11: For loops and Arrays March 8, 2007 ECE 122 Engineering Problem Solving with Java Lecture 11 For Loops and Arrays.
COMP 14: Control Flow: if, if-then May 26, 2000 Nick Vallidis.
COMP 14: Miscellaneous :) May 30, 2000 Nick Vallidis.
COMP 14 Introduction to Programming Miguel A. Otaduy May 20, 2004.
Loops Repetition Statements. Repetition statements allow us to execute a statement multiple times Often they are referred to as loops Like conditional.
© 2004 Pearson Addison-Wesley. All rights reserved5-1 Iterations/ Loops The while Statement Other Repetition Statements.
COMP 14: I/O and Boolean Expressions May 24, 2000 Nick Vallidis.
COMP 110 Introduction to Programming Mr. Joshua Stough September 19, 2007.
COMP 110 Introduction to Programming Mr. Joshua Stough September 24, 2007.
COMP 14: Primitive Data and Objects May 24, 2000 Nick Vallidis.
Day 4 Objectives Constructors Wrapper Classes Operators Java Control Statements Practice the language.
Shorthand operators.
CIS3931 – Intro to JAVA Lecture Note Set 3 19-May-05.
Review Review Review. Concepts Comments: definition, example, different types of comments Class: definition, example Object: definition, example Data.
REPETITION CITS1001. Scope of this lecture Repetition for loops while loops 2.
Copyright © Nancy Acemian 2004 For Loops-Break-Continue COMP For loop is a counter controlled loop. For loop is a pretest loop. Used when number.
October 28, 2015ICS102: For Loop1 The for-loop and Nested loops.
Copyright © 2012 Pearson Education, Inc. Chapter 6 More Conditionals and Loops Java Software Solutions Foundations of Program Design Seventh Edition John.
1 BUILDING JAVA PROGRAMS CHAPTER 2 PRIMITIVE DATA AND DEFINITE LOOPS.
Loops  Did you get the point behind a loop?  Why is there a need for loops? Code JunkiesLoops 1.
1-Dec-15 Additional control structures. 2 The if-else statement The if-else statement chooses which of two statements to execute The if-else statement.
Introduction to Computing Concepts Note Set 15. JOptionPane.showMessageDialog Message Dialog Allows you to give a brief message to the user Can be used.
CSCI 1226 FALL 2015 MIDTERM #1 REVIEWS.  Types of computers:  Personal computers  Embedded systems  Servers  Hardware:  I/O devices: mice, keyboards,
CPSC 217 T03 Week V Part #1: Iteration Hubert (Sathaporn) Hu.
Arrays-. An array is a way to hold more than one value at a time. It's like a list of items.
1 Iterative Structures --- LOOPS zYou can alter the sequential control of flow from 1 statement to the next by: yCalling a function yIterative Statements(loops)
CMSC 150 LOOPS CS 150: Fri 20 Jan Representing DNA AGTCCAGTGTCAA.
1 BUILDING JAVA PROGRAMS CHAPTER 2 PRIMITIVE DATA AND DEFINITE LOOPS.
Introduction to Computers and Programming Lecture 10: For Loops Professor: Evan Korth New York University.
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
CS 106 Introduction to Computer Science I 02 / 15 / 2008 Instructor: Michael Eckmann.
Lecture 4 CS140 Dick Steflik. Reading Keyboard Input Import java.util.Scanner – A simple text scanner which can parse primitive types and strings using.
Chapter 2 Basic Computation
COMP 14 Introduction to Programming
Yanal Alahmad Java Workshop Yanal Alahmad
Chapter 6 More Conditionals and Loops
Primitive Data, Variables, Loops (Maybe)
CiS 260: App Dev I Chapter 4: Control Structures II.
Chapter 2 Basic Computation
Outline Altering flow of control Boolean expressions
The for-loop and Nested loops
An Introduction to Java – Part I, language basics
Variables variable: A piece of the computer's memory that is given a name and type, and can store a value. Like preset stations on a car stereo, or cell.
Building Java Programs
Building Java Programs
Building Java Programs
Program Flow.
Building Java Programs
Building Java Programs
QUIZ 5 – RESULT.
Repetition Statements
Midterm Review October 23, 2006 ComS 207: Programming I (in Java)
Building Java Programs
Additional control structures
Agenda Packages and classes Types and identifiers Operators
Presentation transcript:

COMP 14: Midterm Review June 8, 2000 Nick Vallidis

Announcements zMidterm is tomorrow!

Assignment P4 zJust want to go over it to make sure you all understand...

Instantiating objects  We do this with the keyword new zExamples: String name; name = new String("Vallidis"); Die myDie; myDie = new Die(6);

packages zA package is a group of classes  That's it. In Java, each class has its own.java file and all the.java files in a directory are one package.

Assignment operators mult += value is just the same thing as: mult = mult + value  This is just a shortcut so you don't have to type mult twice!  You can replace + with any of the normal math operators: -, /, %, etc.

Equivalence of loops zAll loops have the same four parts: yinitialization ycondition ystatements (the loop body) yincrement (the loop update -- it doesn't have to be an increment specifically) zAs a result, you can convert between loop types.

Equivalence of loops for (initialization; conditon; update) body;initialization; while (condition)do{body;update;} while (condition);

Nested if statements zWhat's up with this? if (x < 3) if (y > 2) System.out.println("yay!"); else System.out.println("x >= 3");

Nested if statements zwrite nested ifs to do the following: yyou have one integer x ywhen 0<=x<5 print "low" ywhen 5<=x<10 print "medium" ywhen 10<=x<15 print "high" yfor any other value of x don't do anything zCan you do this as a switch statement?

nested loops zwhat does this code do? int i, j; for (i=1; i<=5; i++) { for (j=i; j>=1; j--) System.out.print("*"); System.out.println(); }

nested loops zWrite code to print out a person's name 5 times and then ask if they want to do it again. If they do, then print their name again 5 times (response can be string or integer) Assume the name has already been read and has this declaration: String name;