CS 177 Week 15 Recitation Slides. Review

Similar documents
Final Exam. COMP Summer I June 26, points

CS 101 Spring 2007 Midterm 2 Name: ID:

Introduction to Programming Using Java (98-388)

Exam 1 Prep. Dr. Demetrios Glinos University of Central Florida. COP3330 Object Oriented Programming

Last Time. University of British Columbia CPSC 111, Intro to Computation Alan J. Hu. Readings

CS Introduction to Programming Midterm Exam #1 - Prof. Reed Fall 2009

CS 101 Fall 2006 Midterm 1 Name: ID:

Lecture Programming in C++ PART 1. By Assistant Professor Dr. Ali Kattan

Searching for Information. A Simple Method for Searching. Simple Searching. Class #21: Searching/Sorting I

Two Types of Types. Primitive Types in Java. Using Primitive Variables. Class #07: Java Primitives. Integer types.

CS Introduction to Programming Midterm Exam #1 - Prof. Reed Spring 2010

I. True/False: (2 points each)

1.00 Introduction to Computers and Engineering Problem Solving. Quiz 1 March 7, 2003

McGill University School of Computer Science COMP-202A Introduction to Computing 1

About this exam review

CSE 113 A. Announcements - Lab

Bjarne Stroustrup. creator of C++

CS 177 Recitation. Week 8 Methods

1.5 Input and Output. Introduction to Computer Science Sedgewick and Wayne Copyright 2007

CS 231 Data Structures and Algorithms, Fall 2016

COMP-202: Foundations of Programming. Lecture 2: Variables, and Data Types Sandeep Manjanna, Summer 2015

Agenda CS121/IS223. Reminder. Object Declaration, Creation, Assignment. What is Going On? Variables in Java

CS111: PROGRAMMING LANGUAGE II

CS 101 Spring 2006 Final Exam Name: ID:

COMP 250: Java Programming I. Carlos G. Oliver, Jérôme Waldispühl January 17-18, 2018 Slides adapted from M. Blanchette

Administration. Objects and Arrays. Objects. Agenda. What is an Object? What is a Class?

CS Week 5. Jim Williams, PhD

CS121/IS223. Object Reference Variables. Dr Olly Gotel

CS 102 / CS Introduction to Programming Midterm Exam #1 - Prof. Reed Fall 2010

int a; int b = 3; for (a = 0; a < 8 b < 20; a++) {a = a + b; b = b + a;}

GRAPHICS AND SOUND. Fundamentals of Computer Science I

CS Introduction to Programming Midterm Exam #1 - Prof. Reed Spring 2009

Outline. Parts 1 to 3 introduce and sketch out the ideas of OOP. Part 5 deals with these ideas in closer detail.

Object-Oriented Programming

APCS Semester #1 Final Exam Practice Problems

Final Exam CS 152, Computer Programming Fundamentals December 9, 2016

Review. Primitive Data Types & Variables. String Mathematical operators: + - * / % Comparison: < > <= >= == int, long float, double boolean char

CS 177 Week 5 Recitation Slides. Loops

CS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University

CS 101 Fall 2006 Midterm 3 Name: ID:

Input and output thus far. Graphics and sound Input. New input/output capabilities. Output. StdDraw overview. StdDraw. StdAudio

CSE 332 Autumn 2013: Midterm Exam (closed book, closed notes, no calculators)

Using System.out.println()

More About Classes CS 1025 Computer Science Fundamentals I Stephen M. Watt University of Western Ontario

CS 251L Review Quiz Key

CS 251 Intermediate Programming Java Basics

Selected Questions from by Nageshwara Rao

Getting started with Java

CS 177 Spring 2009 Final Exam

Practice Midterm 1 Answer Key

Simple Java YEAH Hours. Brahm Capoor and Vrinda Vasavada

Getting started with Java

A Foundation for Programming

CS 251 Intermediate Programming Methods and Classes

CS 251 Intermediate Programming Methods and More

COMP-202: Foundations of Programming. Lecture 26: Image Manipulation; Wrap-Up Jackie Cheung, Winter 2015

Midterm Review Topics Java Basics and Structure Variables Branching Loops Methods Arrays. Midterm Review Kage Weiss Lab 001 TA, SPR 17

ECE 122. Engineering Problem Solving with Java

ECE 122. Engineering Problem Solving with Java

Assignment 2.4: Loops

CIS 110 Introduction to Computer Programming. February 29, 2012 Midterm

Computer Science II (20082) Week 1: Review and Inheritance

COE318 Lecture Notes Week 4 (Sept 26, 2011)

Practice Midterm 1. Problem Points Score TOTAL 50

I. True/False: (2 points each) On your bubble form fill out a for true and b for false.

CSCE 145 Exam 1 Review. This exam totals to 100 points. Follow the instructions. Good luck!

What did we talk about last time? Examples switch statements

Debugging [continued]

Remedial classes. G51PRG: Introduction to Programming Second semester Lecture 2. Plan of the lecture. Classes and Objects. Example: Point class

BASIC COMPUTATION. public static void main(string [] args) Fundamentals of Computer Science I

CS Introduction to Programming Midterm Exam #1 - Prof. Reed Spring What is your name?: (4 points for writing it on your answer sheet)

CSE 143 SAMPLE MIDTERM

Final Exam COMP Fall 2004 Dec 16, 2004

Review: Object Diagrams for Inheritance. Type Conformance. Inheritance Structures. Car. Vehicle. Truck. Vehicle. conforms to Object

CS 102/107 - Introduction to Programming Midterm Exam #2 - Prof. Reed Spring 2011

Lecture 2. COMP1406/1006 (the Java course) Fall M. Jason Hinek Carleton University

CSE115 Introduction to Computer Science I Coding Exercise #7 Retrospective Fall 2017

Object Oriented Programming: In this course we began an introduction to programming from an object-oriented approach.

Loops. CSE 114, Computer Science 1 Stony Brook University

} Evaluate the following expressions: 1. int x = 5 / 2 + 2; 2. int x = / 2; 3. int x = 5 / ; 4. double x = 5 / 2.

AP Computer Science Unit 1. Programs

CIS 110 Introduction To Computer Programming. February 29, 2012 Midterm

Problem Grade Total

ECE 122 Engineering Problem Solving with Java

SPRING 13 CS 0007 FINAL EXAM V2 (Roberts) Your Name: A pt each. B pt each. C pt each. D or 2 pts each

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 8: SEP. 29TH INSTRUCTOR: JIAYIN WANG

Mobile Computing Professor Pushpendra Singh Indraprastha Institute of Information Technology Delhi Java Basics Lecture 02

Exam 1. CSC 121 Spring Lecturer: Howard Rosenthal. March 1, 2017

CSC Java Programming, Fall Java Data Types and Control Constructs

Materials covered in this lecture are: A. Completing Ch. 2 Objectives: Example of 6 steps (RCMACT) for solving a problem.

Lecture 13: Two- Dimensional Arrays

Midterm I - CSE11 Fall 2013 CLOSED BOOK, CLOSED NOTES 50 minutes, 100 points Total.

Inf1-OP. Inf1-OP Exam Review. Timothy Hospedales, adapting earlier version by Perdita Stevens and Ewan Klein. March 20, School of Informatics

Course Outline. Introduction to java

Lecture 6. Assignments. Java Scanner. User Input 1/29/18. Reading: 2.12, 2.13, 3.1, 3.2, 3.3, 3.4

Arrays and ArrayLists. David Greenstein Monta Vista High School

CSC 1351: Exam 2: Midterm

Curriculum Map Grade(s): Subject: AP Computer Science

CMPS 12A Winter 2006 Prof. Scott A. Brandt Final Exam, March 21, Name:

CLASSES AND OBJECTS. Fundamentals of Computer Science I

Transcription:

CS 177 Week 15 Recitation Slides Review 1

Announcements Final Exam on Friday Dec. 18 th STEW 183 from 1 3 PM Complete your online review of your classes. Your opinion matters!!! Project 6 due Just kidding 2

How to Study Know every detail of previous exams you have taken. If there is something you DON T understand, look it up, Google it and ask questions! Review the slides. Recitation slides are a summary of each week s lecture. Good to review both; they will compliment one another. Understand your labs and projects as though you had to re-program them from scratch. Re-program key parts and ** learn how to trace a program ** Use the book to fill in any question areas. DO NOT ONLY RELY ON THE EXAMPLE FINAL!!!!! 3

Remember the Good Ole Days Compile and run a program called Program.java: javac Program.java java Program Difference between System.out.println() and System.out.print()? println() adds a new line at the end of the printed statement Java is case sensitive: VarName is different from varname. 4

Primitive Data Types: Type Kind of values Sample Literals int double boolean char Integers Floating-point Numbers Boolean values Single characters -5 0 900031 3.14-0.6 6.02e23 true false A Z & String Sequences of charaters Hello World Goodbye 5

From example exam: 6

Conditionals if statements use a boolean expression and execute a set of statements if the expression is true. There may be a corresponding else block that handles cases where the expression is false Switch statements allow for the use of choices of several values, but must only be equality relationships for integers and characters. if(<boolean Expression>) else <Statement1> <Statement2> switch(data) { case val1: <Statement1> (break;) case val2: <Statement2> (break;) default: <Statement3> } 7

Loops For loops Count controlled While loops Event controlled Do/While Event controlled loops that need to execute AT LEAST once Conditions in loops are ways to enter the loop but also the condition on which to leave the loop The STOP condition (Keep going until ) 8

Example: 9

Arrays Multiple elements stored and accessed together via the same variable name, with indices 0 (length of array-1) All elements must be the same type To declare an array called example of 100 integers: int example = new int[100]; To create an array with initial elements, you can use: int example = {1, 2, 3, 4, 5}; 10

Example with arrays and loops 11

What if i started with 0? 12

Input Output java ProgramOut > output.txt java ProgramIn < output.txt OR java ProgramOut java ProgramIn 13

StdDraw Method void line(double x0, double y0, double x1, double y1) void point(double x, double y) Method void circle(double x, double y, double r) void filledcircle(double x, double y, double r) void square(double x, double y, double r) void filledsquare(double x, double y, double r) void setpencolor(color c) Use Draw a line from (x0,y0) to (x1,y1) Draw a point at (x,y) Use Draw a circle centered at (x,y) with radius r Draw a filled circle centered at (x,y) with radius r Draw a square centered at (x,y) with edges 2r Draw a filled square centered at (x,y) with edges 2r Start drawing with color c 14

Methods public static type methodname(type name1, type namen) or private optional return type public int calculatesum(int[] array) { int sum = 0; for(int i = 0; i < array.length; i++) sum += array[i]; } return sum; 15

16

Audio Digital audio is made by sampling the heights of the sound wave many times per second CD quality audio samples at 44,100 Hz The frequency of the wave determines how high or low the wave sounds The height of the peaks from the troughs (amplitude) determines the loudness (volume) StdAudio lets us load WAV files as an array of samples in the range [-1.0,1,0] and save such arrays as WAV files 17

Method static double[] read(string file) static void save(string file, double[] input) static void play(string file) static void play(double[] input) Use Read a WAV file into an array of doubles Save an array of doubles (samples) into a WAV file Play a WAV file Play an array of doubles (samples) 18

Classes and Objects public class Name { private type member1; private type member2; //member variables } public Name( ) { //constructor. } //other methods. 19

Objects and Classes cont. Objects behave differently from primitive data types Reference variables are used to keep track of objects When a reference is first declared, its value is null If you try to use the methods or members of a null reference, your program will crash Multiple references can point at a single object Changing the object that they point to will change it for all references 20

Objects contain Members Methods Members are the data inside of objects, and they are usually private Methods are ways of accessing and modifying that data, and they are usually public 21

22

23

Running Time and Performance Not every solution that works is the best solution to use. Sometimes, even if a program works, it can be too slow. Usually depends on how many loops and how many nested loops there are. 24

Searching and Sorting Searching Can be done in O(n) time by just scanning through the array Can be done in O(log n) time if the array is sorted by playing a high-low game called binary search Sorting Cutting the search space in half every time It s an algorithm that works well even with very large n Relatively simple methods take O(n 2 ) time The best possible is O(n log n) time 25

Sorting Many possible ways of sorting. The more efficient, the more difficult to program Bubble Sort Insertion Sort Merge Sort Bucket Sort (Many others ) SHOULD BECOME FAMILIAR WITH ALGORITHMS FROM SLIDES!!!!! 26

27

28

ANY QUESTIONS 29

QUIZ Using what you know and the remaining time, write down a question and answer that shows something you have learned this semester. Don t forget your name in the process (Please do not get over zealous where you may not be able to finish on time.) GOOD LUCK ON THE FINAL (AND DON T FORGET EVALUATIONS!!!) 30