CS 180 Problem Solving and Object Oriented Programming Fall 2010

Size: px
Start display at page:

Download "CS 180 Problem Solving and Object Oriented Programming Fall 2010"

Transcription

1 CS 180 Problem Solving and Object Oriented Programming Fall 2010 hmp:// This Week: Notes for Week 7: Oct 4 8, 2010 Aditya Mathur Department of Computer Science Purdue University West LafayeMe, IN, USA 10/4 10/6 1. Exam 1: Performance 2. Project 1: Performance 3. Feedback for Week 6 4. Arrays 5. Demo 6. Incremental program development 7. MulW dimensional arrays 8. Visual depicwon of arrays

2 Readings and Exercises for Week 7 Readings: Chapter 6: 6.1, 6.2, 6.3, 6.4 Exercises: 6.3, 6.4, 6.5, 6.7 Aditya Mathur. CS 180. Fall Week 7 2

3 Special help session Thursday Oct 7, 5 7pm: Special help session in the B158 Sunday October 10: No help session. Enjoy your break! Aditya Mathur. CS 180. Fall Week 7 3

4 Special class Sunday October 17: 4 5:30pm For those who have not been able to perform well on Exam 1 and/or Project 1. Send me if you wish to amend. Bring your laptops. Aditya Mathur. CS 180. Fall Week 7 4

5 Lunch meewng When: Thursday October 7, Noon 1:30pm Where: Ford Dining Hall Meet: Upstairs in the Ford dining hall AMendees: All who signed up for September 30 and October 7 Look forward to seeing you! Aditya Mathur. CS 180. Fall Week 7 5

6 Performance: Exam 1 Overall: Count: 231 Average: 393.3/480 Max Score: 480 obtained by 11 students Median: Standard deviawon: 78.2 Part B: Count: 231 Average: 59.7 Max Score: 70/70 scored by 40 students Median: 63.0 Standard deviawon: Aditya Mathur. CS 180. Fall Week 7 6

7 Performance: Exam 1: Histogram Aditya Mathur. CS 180. Fall Week 7 7

8 Exam 1: Common mistakes: Q1 Incorrect types for coordinates (int instead of float or double) 3 to 5 points Incorrect or forgomen formadng 3 points Code in main() method instead of in constructor 2 points Incorrect coding of the distance formula 10 to 20 points Aditya Mathur. CS 180. Fall Week 7 8

9 Exam 1: Common mistakes: Q2 Incorrect random number generawon ( 2 to 15 points) Minor syntax errors ( 1 to 2 points). Code in main() instead of constructor ( 3 points). Incorrect datatype for min, max ( 2 points) Incorrect class structure, like constructor inside main() ( 2 to 5 points) Not *reading* min and max from user ( 5 points) Incorrect if condiwons ( 2 to 5 points) Aditya Mathur. CS 180. Fall Week 7 9

10 Performance: Project 1 Total graded: 222 Average: 60.7 Max score: 64 by 81 students 59 63: 105 students Median: 62 Standard deviawon: 7.23 Aditya Mathur. CS 180. Fall Week 7 10

11 Robots in labs Please take a survey in this week s lab Please do not toast us! The robots were intended to give you some thrill and help in understanding the challenges of programming embedded systems. Unfortunately, the Ridge Sok robots turned out to be unreliable devices! Aditya Mathur. CS 180. Fall Week 7 11

12 Feedback for Week 6 Aditya Mathur. CS 180. Fall Week 7 12

13 Q1. The lab exercises were useful (Use scale of 1 10: 10 most useful, 1 not useful at all) (a) 8 10 (b) 4 7 (c) 1 3 (d) Missed Week 6 lab Aditya Mathur. CS 180. Fall Week 7 13

14 Q2. The recitawon exercises were useful (Use scale of 1 10: 10 most useful, 1 not useful at all) (a) 8 10 (b) 4 7 (c) 1 3 (d) Missed 6 recitawon Aditya Mathur. CS 180. Fall Week 7 14

15 Q3. The recitawon instructor was helpful. (Use scale of 1 10: 10 most helpful, 1 not helpful at all) (a) 8 10 (b) 4 7 (c) 1 3 (d) Missed week 6 recitawon Aditya Mathur. CS 180. Fall Week 7 15

16 Q4 Exam 1 was (a) Very easy (b) Somewhat easy (c) Somewhat tough (d) Tough (e) Very tough Aditya Mathur. CS 180. Fall Week 7 16

17 Q5. I have completed Project 2 (a) Yes (b) Nearly complete (c) Not started Aditya Mathur. CS 180. Fall Week 7 17

18 Q6. So far I am liking the course (a) A lot (b) Somewhat (c) Not sure Aditya Mathur. CS 180. Fall Week 7 18

19 Arrays Aditya Mathur. CS 180. Fall Week 7 19

20 Arrays: What are these? A homogeneous collecwon of variables or objects. All elements of an array are of the same type. Examples: Array of integers where each integer represents the age of a pawent. Array of cars where each element of the array denotes a specific car. Array of flowers where each element of the array denotes a flower. Aditya Mathur. CS 180. Fall Week 7 20

21 Arrays: When to use? When there is a need to retain data in memory for efficient processing. Data is created once and used many Wmes. Examples: Array of flights: Search for a specific flight Array of cars: Search for a specific car, or find the average price. Array of laptops: find the cheapest laptop Aditya Mathur. CS 180. Fall Week 7 21

22 Declaring an Array Indicates age is an array variable int [] age; /* age refers to an array of integers; e.g. age of people in a database*/ double [] weight; /* weight refers to an array of doubles; e.g. weights of items shipped*/ String [] name; /* name refers to an array of elements each of type String; e.g., names of people in a database*/ Aditya Mathur. CS 180. Fall Week 7 22

23 Declaring an Array: of objects Bird [] bird; /* Bird refers to a class; bird is an array where each element is an object of type Bird. */ Aircrak [] fleet; /* Aircrak refers to a class; fleet is an array where each element is an object of type Aircrak. */ Aditya Mathur. CS 180. Fall Week 7 23

24 CreaWng an Array int [] age=new int[10]; /* age is an array of 10 elements each of type int*/ double [] weight=new double[100]; /* weight is an array of 100 elements each of type double*/ String [] name=new String[15]; /* name is an array of 15 elements each of type String*/ Aircrak [] fleet=new Aircrak[150]; /* fleet is an array of 150 elements each of type Aircrak*/ Aditya Mathur. CS 180. Fall Week 7 24

25 Accessing an array element: general syntax Name of the array Index, starts from 0, must be an int Examples: name [expression] age[i]; // 0<=i<10 fleet[k]; // 0<=k<150 weight[i+j]; // 0<=(i+j)<100 Note: First element of an array is located at index 0. Aditya Mathur. CS 180. Fall Week 7 25

26 Accessing an array element int [] age=new int[10]; int p= age[5]; /* p gets element at index 5 of array age*/ double [] weight=new double[100]; double hisweight=weight[i]; /* hisweight gets the element of weight at index i*/ Aircrak [] fleet=new Aircrak[150]; Aircrak rental=fleet[k]/* rental gets the element of fleet located at index k */ Aditya Mathur. CS 180. Fall Week 7 26

27 Assigning a value to an array element int [] age=new int[10]; age[i]=15; /* (i+1) th element of age becomes 15. */ int [] age={ 15, 20, 30} // All elements iniwalized double [] weight=new double[100]; weight[k]=weight[k] 10; /* (k+1) th element of the weight is decremented by 10.*/ Aircrak [] fleet=new Aircrak[150]; fleet[i]=new Aircrak(); /* (i+1) th element of fleet gets a new Aircrak */ Aditya Mathur. CS 180. Fall Week 7 27

28 IteraWng through elements of an array In many problems we need to iterate through all or a few of the elements of an array. Such an iterawon is accomplished by using a for or a while loop. Aditya Mathur. CS 180. Fall Week 7 28

29 Problem: Find average int agesum=0; // IniWalize sum of all ages int [] age=new int[10]; // Create array of int to hold ages for( int i=0; i<age.length; i++){ agesum=agesum+age[i]; // Accumulate ages } double average=agesum/(double)age.length; Aditya Mathur. CS 180. Fall Week 7 29

30 Problem: Search in an array String [] wlist={"emilio", "Semion", "Osama"}; Scanner s=new Scanner (System.in); String wanted=s.next(); // Get name to be searched boolean found=false; // Not yet found int next=0; // Points to the first element in wanted list while(next<wlist.length &&!found) { if(wanted.equals(wlist[nextitem])) // Compare found=true; // If equal then we have found the wanted! else next++; // else point to the next item on the list }//End of loop Aditya Mathur. CS 180. Fall Week 7 30

31 Problem: Search in an array if(found) System.out.println(wanted+ " exists in database"); else System.out.println(wanted+ " not in database") } // End of program Aditya Mathur. CS 180. Fall Week 7 31

32 Problem: Statement A plant biology lab maintains a collecwon of leaves. The lab director wishes to create a simple database that contains several entries. Each entry is a plant name, type of its leaf, and a brief descripwon of the leaf in the collecwon. Example: WhitePine Needle NA Heather Compound NA Write a program that reads data from a file as menwoned above and allows a user to search for a tree in the database. Aditya Mathur. CS 180. Fall Week 7 32

33 Problem: Understanding A plant biology lab maintains a collecwon of leaves. From where can my program read the leaf data? If it is in a file, then what is the name of that file? The lab director wishes to create a simple database that contains several entries. How much data is available? Write a program that reads data from a file as menwoned above and allows a user to search for a tree in the database. In what form will the user input a request? Aditya Mathur. CS 180. Fall Week 7 33

34 Java program for plant biology lab. Incremental stepwise development! Aditya Mathur. CS 180. Fall Week 7 34

35 Tasks 1. Read plant collecwon data from a file 2. Provide search service to the user 3. Exit with a bye bye message when done. Aditya Mathur. CS 180. Fall Week 7 35

36 Let us assume. 1. LeafCollecWon class is available 2. It provides the following methods: createcollec?on() searchservice() 3. Leaf class is available. It provides the following methods: public void gettree(); public void getleaftype(); public void getdescrip?ontype(); Why did we make the above assumpwons? Aditya Mathur. CS 180. Fall Week 7 36

37 Overall design: Classes LeafCollecWonServer Main server Ini?ates ac?ons Uses LeafCollecWon public void createcollec?on(); public void (); Leaf private String parentplant; private String leaftype; private String leafdescripwon; public void gettree(); public void getleaftype(); public void getdescrip?ontype(); Uses Aditya Mathur. CS 180. Fall Week 7 37

38 LeafCollecWonServer Back to the Java program. Version 1.0. Aditya Mathur. CS 180. Fall Week 7 38

39 LeafCollecWon: Design This is a class. Provides two methods: createcollec?on() searchservice() But before we can write these methods we must have a way to read from a file and save in memory all the data about the collecwon! QuesWon: How should we store leaf collecwon data? Recall: For each leaf, we have its parent tree, its type, and its descrip?on. Aditya Mathur. CS 180. Fall Week 7 39

40 LeafCollecWon: Design QuesWon QuesWon: How should we store leaf collecwon data? Recall: For each leaf, we have its parent tree, its type, and its descrip?on. Answer:?? Aditya Mathur. CS 180. Fall Week 7 40

41 LeafCollecWon Back to the Java program. Version 2.0. Aditya Mathur. CS 180. Fall Week 7 41

42 Leaf: Design: AMributes Recall, for each leaf, we have the following available data: Name of parent tree Name of the leaf DescripWon Aditya Mathur. CS 180. Fall Week 7 42

43 Leaf: Design: Methods Recall, for each leaf, we have the following available data: public String getleafname(); public String gettreename(); public String getdsecripwon(); Aditya Mathur. CS 180. Fall Week 7 43

44 Leaf class Back to the Java program. Version 3.0. Aditya Mathur. CS 180. Fall Week 7 44

45 Arrays: Visual representawon Aditya Mathur. CS 180. Fall Week 7 45

46 Single dimensional array: Example 1 int [] cloudydays=new int [12] // average cloudy days/month Anchorage, Alaska [ ] Index Data cloudydays[0] cloudydays[5] cloudydays[11] Aditya Mathur. CS 180. Fall Week 7 46

47 Single dimensional array: Example 2: DeclaraWon Car [] carstock=new Car [5] // Cars at a dealership public class Car{ String make; // e.g. Ford String model; // e.g. Fusion int year; // e.g long msrp; // e.g. US$23145 Picture carpic; } Aditya Mathur. CS 180. Fall Week 7 47

48 Single dimensional array: Example 2: Visual Car [] carstock=new Car[5] // Cars at a dealership CS180 Dealership in West LafayeMe [ ] Index Object Reference {Ford, fusion, 2011, }... {Porsche, Boxster Spyder, 2011, 72000, } } carstock[0] carstock[4] Aditya Mathur. CS 180. Fall Week 7 48

49 Arrays: MulWdimensional Aditya Mathur. CS 180. Fall Week 7 49

50 Example 1 MEAN MONTHLY CLOUDY DAYS IN ARIZONA J F M A M J J A S O N D FLAGSTAFF PHOENIX TUCSON WINSLOW YUMA rows columns int [][] cloudydays=new int [5][12] What is the value of cloudydays[1,8]? Aditya Mathur. CS 180. Fall Week 7 50

51 DeclaraWon Cars [] inventory=new Car [3][]; 3 rows and undefined number of columns Each row represents make of a car and column represents models Chevy Honda Toyota Avalanche Traverse Accord Fit Civic Camry Corolla Rav4 Aditya Mathur. CS 180. Fall Week 7 51

52 Arrays: Typical errors Index out of bounds [Run Wme error] int [] a=new int [10]; a[i]=x; // i is greater than 9 or less than 0 Element not iniwalized [Compile Wme error] String [] name; name[i]= Bob ; // element not iniwalized Aditya Mathur. CS 180. Fall Week 7 52

53 Week 7: October 4 8, 2010 Hope you enjoyed this week! QuesWons? Contact your recitawon instructor. Make full use of our office hours. Aditya Mathur. CS 180. Fall Week 7 53

CS 180 Problem Solving and Object Oriented Programming Fall 2011

CS 180 Problem Solving and Object Oriented Programming Fall 2011 CS 180 Problem Solving and Object Oriented Programming Fall 2011 hmp://www.cs.purdue.edu/homes/apm/courses/cs180fall2011/ This Week: Notes for Week 7: Oct 3-7, 2011 Aditya Mathur Department of Computer

More information

CS 180 Problem Solving and Object Oriented Programming Fall 2011

CS 180 Problem Solving and Object Oriented Programming Fall 2011 CS 180 Problem Solving and Object Oriented Programming Fall 2011 hmp://www.cs.purdue.edu/homes/apm/courses/cs180fall2011/ This Week: Notes for Week 9: Oct 17-21, 2011 Aditya Mathur Department of Computer

More information

CS 180 Problem Solving and Object Oriented Programming Fall 2011

CS 180 Problem Solving and Object Oriented Programming Fall 2011 CS 180 Problem Solving and Object Oriented Programming Fall 20 hmp://www.cs.purdue.edu/homes/apm/courses/cs180fall20/ Notes for Week : Oct 31- Nov 4, 20 Aditya Mathur Department of Computer Science Purdue

More information

CS 180 Problem Solving and Object Oriented Programming Fall 2011

CS 180 Problem Solving and Object Oriented Programming Fall 2011 CS 180 Problem Solving and Object Oriented Programming Fall 2011 hlp://www.cs.purdue.edu/homes/apm/courses/cs180fall2011/ Notes for Week 2: August 29- September 2, 2011 Aditya Mathur Department of Computer

More information

CS 180 Problem Solving and Object Oriented Programming Fall 2011

CS 180 Problem Solving and Object Oriented Programming Fall 2011 CS 180 Problem Solving and Object Oriented Programming Fall 2011 hmp://www.cs.purdue.edu/homes/apm/courses/cs180fall2011/ This Week: Notes for Week : Nov 21-25, 2011 11/21 1. Review 2. Class BufferedImage

More information

CS 180 Problem Solving and Object Oriented Programming Fall 2011

CS 180 Problem Solving and Object Oriented Programming Fall 2011 CS 180 Problem Solving and Object Oriented Programming Fall 2011 hlp://www.cs.purdue.edu/homes/apm/courses/cs180fall2011/ This Week: Notes for Week : Nov 28- Dec 2, 2011 11/28-30 1. ExcepUons 2. Recursion

More information

Introduction to Programming Using Java (98-388)

Introduction to Programming Using Java (98-388) Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;

More information

Introduction to Computer Science Midterm 3 Fall, Points

Introduction to Computer Science Midterm 3 Fall, Points Introduction to Computer Science Fall, 2001 100 Points Notes 1. Tear off this sheet and use it to keep your answers covered at all times. 2. Turn the exam over and write your name next to the staple. Do

More information

Use the Scantron sheets to write your answer. Make sure to write your Purdue ID (NOT Purdue Login ID) and your name on the Scantron answer sheet.

Use the Scantron sheets to write your answer. Make sure to write your Purdue ID (NOT Purdue Login ID) and your name on the Scantron answer sheet. Department of Computer Science Purdue University, West Lafayette Fall 2011: CS 180 Problem Solving and OO Programming Final Examination: Part A. You may consult the textbook and your hand written notes.

More information

CSC 111 Introduction to Computer Science (Section C)

CSC 111 Introduction to Computer Science (Section C) CSC 111 Introduction to Computer Science (Section C) Course Description: (4h) Lecture and laboratory. Rigorous introduction to the process of algorithmic problem solving and programming in a modern programming

More information

Review Problems for Final Exam. 1. What is the output of the following program? #include <iostream> #include <string> using namespace std;

Review Problems for Final Exam. 1. What is the output of the following program? #include <iostream> #include <string> using namespace std; Review Problems for Final Exam 1. What is the output of the following program? int draw(int n); int n = 4; while (n>0) n = draw(n); int draw(int n) for(int i = 0; i < n; i++) cout

More information

Announcements. Lab Friday, 1-2:30 and 3-4:30 in Boot your laptop and start Forte, if you brought your laptop

Announcements. Lab Friday, 1-2:30 and 3-4:30 in Boot your laptop and start Forte, if you brought your laptop Announcements Lab Friday, 1-2:30 and 3-4:30 in 26-152 Boot your laptop and start Forte, if you brought your laptop Create an empty file called Lecture4 and create an empty main() method in a class: 1.00

More information

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

Review: Object Diagrams for Inheritance. Type Conformance. Inheritance Structures. Car. Vehicle. Truck. Vehicle. conforms to Object Review: Diagrams for Inheritance - String makemodel - int mileage + (String, int) Class #3: Inheritance & Polymorphism Software Design II (CS 220): M. Allen, 25 Jan. 18 + (String, int) + void

More information

CSE 113 A. Announcements - Lab

CSE 113 A. Announcements - Lab CSE 113 A February 21-25, 2011 Announcements - Lab Lab 1, 2, 3, 4; Practice Assignment 1, 2, 3, 4 grades are available in Web-CAT look under Results -> Past Results and if looking for Lab 1, make sure

More information

CS 101, Spring 2016 March 22nd Exam 2

CS 101, Spring 2016 March 22nd Exam 2 CS 101, Spring 2016 March 22nd Exam 2 Name: Question 1. [3 points] Which of the following loop statements would most likely cause the loop to execute exactly n times? You may assume that n will be set

More information

Lecture Transcript While and Do While Statements in C++

Lecture Transcript While and Do While Statements in C++ Lecture Transcript While and Do While Statements in C++ Hello and welcome back. In this lecture we are going to look at the while and do...while iteration statements in C++. Here is a quick recap of some

More information

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

McGill University School of Computer Science COMP-202A Introduction to Computing 1 McGill University School of Computer Science COMP-202A Introduction to Computing 1 Midterm Exam Thursday, October 26, 2006, 18:00-20:00 (6:00 8:00 PM) Instructors: Mathieu Petitpas, Shah Asaduzzaman, Sherif

More information

CS 180 Problem Solving and Object Oriented Programming Fall 2011

CS 180 Problem Solving and Object Oriented Programming Fall 2011 CS 180 Problem Solving and Object Oriented Programming Fall 2011 hlp://www.cs.purdue.edu/homes/apm/courses/cs180fall2011/ This Week: Notes for Week : Oct 24-28, 2011 Aditya Mathur Department of Computer

More information

H212 Introduction to Software Systems Honors

H212 Introduction to Software Systems Honors Introduction to Software Systems Honors Lecture #04: Fall 2015 1/20 Office hours Monday, Wednesday: 10:15 am to 12:00 noon Tuesday, Thursday: 2:00 to 3:45 pm Office: Lindley Hall, Room 401C 2/20 Printing

More information

You must pass the final exam to pass the course.

You must pass the final exam to pass the course. Computer Science Technology Department Houston Community College System Department Website: http://csci.hccs.cc.tx.us CRN: 46876 978-1-4239-0146-4 1-4239-0146-0 Semester: Fall 2010 Campus and Room: Stafford

More information

Repetition Structures

Repetition Structures Repetition Structures Chapter 5 Fall 2016, CSUS Introduction to Repetition Structures Chapter 5.1 1 Introduction to Repetition Structures A repetition structure causes a statement or set of statements

More information

Computer Science II Data Structures

Computer Science II Data Structures Computer Science II Data Structures Instructor Sukumar Ghosh 201P Maclean Hall Office hours: 10:30 AM 12:00 PM Mondays and Fridays Course Webpage homepage.cs.uiowa.edu/~ghosh/2116.html Course Syllabus

More information

CSCI-1200 Data Structures Fall 2012 Lecture 5 Pointers, Arrays, Pointer Arithmetic

CSCI-1200 Data Structures Fall 2012 Lecture 5 Pointers, Arrays, Pointer Arithmetic CSCI-1200 Data Structures Fall 2012 Lecture 5 Pointers, Arrays, Pointer Arithmetic Announcements: Test 1 Information Test 1 will be held Tuesday, September 18th, 2012 from 2-3:50pm in West Hall Auditorium.

More information

CS110D: PROGRAMMING LANGUAGE I

CS110D: PROGRAMMING LANGUAGE I CS110D: PROGRAMMING LANGUAGE I Computer Science department Lecture 5&6: Loops Lecture Contents Why loops?? While loops for loops do while loops Nested control structures Motivation Suppose that you need

More information

CS Computer Science I

CS Computer Science I CS 1309-001 Computer Science I Fall 2017, Sul Ross State University Instructor: Dr. Kennard Laviers Office Location: ACR 107 Office Phone: 432-837- 8500 Email: kennard.laviers@sulross.edu Office Hours:

More information

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

Final Exam CS 152, Computer Programming Fundamentals December 9, 2016 Final Exam CS 152, Computer Programming Fundamentals December 9, 2016 Name: NetID: Answer all questions in the space provided. Write clearly and legibly, you will not get credit for illegible or incomprehensible

More information

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

Materials covered in this lecture are: A. Completing Ch. 2 Objectives: Example of 6 steps (RCMACT) for solving a problem. 60-140-1 Lecture for Thursday, Sept. 18, 2014. *** Dear 60-140-1 class, I am posting this lecture I would have given tomorrow, Thursday, Sept. 18, 2014 so you can read and continue with learning the course

More information

CMPSC 111 Introduction to Computer Science I Fall 2016 Lab 8 Assigned: October 26, 2016 Due: November 2, 2016 by 2:30pm

CMPSC 111 Introduction to Computer Science I Fall 2016 Lab 8 Assigned: October 26, 2016 Due: November 2, 2016 by 2:30pm 1 CMPSC 111 Introduction to Computer Science I Fall 2016 Lab 8 Assigned: October 26, 2016 Due: November 2, 2016 by 2:30pm Objectives To enhance your experience with designing and implementing your own

More information

AP Computer Science Summer Work Mrs. Kaelin

AP Computer Science Summer Work Mrs. Kaelin AP Computer Science Summer Work 2018-2019 Mrs. Kaelin jkaelin@pasco.k12.fl.us Welcome future 2018 2019 AP Computer Science Students! I am so excited that you have decided to embark on this journey with

More information

CS 142 Style Guide Grading and Details

CS 142 Style Guide Grading and Details CS 142 Style Guide Grading and Details In the English language, there are many different ways to convey a message or idea: some ways are acceptable, whereas others are not. Similarly, there are acceptable

More information

CS 161. SAMPLE FINAL Fall 2014

CS 161. SAMPLE FINAL Fall 2014 CS 161 SAMPLE FINAL Fall 2014 1. What are the three parts of a loop? How are those three things organized in a while loop? How are they organized in a for loop? 2. Write the code to declare MyStuff to

More information

CSCI 355 Lab #2 Spring 2007

CSCI 355 Lab #2 Spring 2007 CSCI 355 Lab #2 Spring 2007 More Java Objectives: 1. To explore several Unix commands for displaying information about processes. 2. To explore some differences between Java and C++. 3. To write Java applications

More information

CS 180 Problem Solving and Object Oriented Programming Fall 2011

CS 180 Problem Solving and Object Oriented Programming Fall 2011 CS 180 Problem Solving and Object Oriented Programming Fall 2011 hmp://www.cs.purdue.edu/homes/apm/courses/cs180fall2011/ This Week: Notes for Week 6: September 26 30, 2011 Aditya Mathur Department of

More information

This exam is open book. Each question is worth 3 points.

This exam is open book. Each question is worth 3 points. This exam is open book. Each question is worth 3 points. Page 1 / 15 Page 2 / 15 Page 3 / 12 Page 4 / 18 Page 5 / 15 Page 6 / 9 Page 7 / 12 Page 8 / 6 Total / 100 (maximum is 102) 1. Are you in CS101 or

More information

CSCI 355 LAB #2 Spring 2004

CSCI 355 LAB #2 Spring 2004 CSCI 355 LAB #2 Spring 2004 More Java Objectives: 1. To explore several Unix commands for displaying information about processes. 2. To explore some differences between Java and C++. 3. To write Java applications

More information

Reviewing for the Midterm Covers chapters 1 to 5, 7 to 9. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013

Reviewing for the Midterm Covers chapters 1 to 5, 7 to 9. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013 Reviewing for the Midterm Covers chapters 1 to 5, 7 to 9 Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013 2 Things to Review Review the Class Slides: Key Things to Take Away Do you understand

More information

Arrays: Higher Dimensional Arrays. CS0007: Introduction to Computer Programming

Arrays: Higher Dimensional Arrays. CS0007: Introduction to Computer Programming Arrays: Higher Dimensional Arrays CS0007: Introduction to Computer Programming Review If the == operator has two array variable operands, what is being compared? The reference variables held in the variables.

More information

Introduction to Data Structures

Introduction to Data Structures 15-121 Introduction to Data Structures Lecture #1 Introduction 28 August 2019 Margaret Reid-Miller Today Course Administration Overview of Course A (very basic) Java introduction Course website: www.cs.cmu.edu/~mrmiller/15-121

More information

Practice Midterm 1. Problem Points Score TOTAL 50

Practice Midterm 1. Problem Points Score TOTAL 50 CS 120 Software Design I Spring 2019 Practice Midterm 1 University of Wisconsin - La Crosse February 25 NAME: Do not turn the page until instructed to do so. This booklet contains 10 pages including the

More information

INF 315E Introduction to Databases School of Information Fall 2015

INF 315E Introduction to Databases School of Information Fall 2015 INF 315E Introduction to Databases School of Information Fall 2015 Class Hours: Tuesday & Thursday10:30 am-12:00 pm Instructor: Eunyoung Moon Email: eymoon@utexas.edu Course Description Almost every website

More information

Example: Monte Carlo Simulation 1

Example: Monte Carlo Simulation 1 Example: Monte Carlo Simulation 1 Write a program which conducts a Monte Carlo simulation to estimate π. 1 See https://en.wikipedia.org/wiki/monte_carlo_method. Zheng-Liang Lu Java Programming 133 / 149

More information

CS31 Discussion 1E. Jie(Jay) Wang Week1 Sept. 30

CS31 Discussion 1E. Jie(Jay) Wang Week1 Sept. 30 CS31 Discussion 1E Jie(Jay) Wang Week1 Sept. 30 About me Jie Wang E-mail: holawj@gmail.com Office hour: Wednesday 3:30 5:30 BH2432 Thursday 12:30 1:30 BH2432 Slides of discussion will be uploaded to the

More information

Condition-Controlled Loop. Condition-Controlled Loop. If Statement. Various Forms. Conditional-Controlled Loop. Loop Caution.

Condition-Controlled Loop. Condition-Controlled Loop. If Statement. Various Forms. Conditional-Controlled Loop. Loop Caution. Repetition Structures Introduction to Repetition Structures Chapter 5 Spring 2016, CSUS Chapter 5.1 Introduction to Repetition Structures The Problems with Duplicate Code A repetition structure causes

More information

Handout 4 Conditionals. Boolean Expressions.

Handout 4 Conditionals. Boolean Expressions. Handout 4 cs180 - Programming Fundamentals Fall 17 Page 1 of 8 Handout 4 Conditionals. Boolean Expressions. Example Problem. Write a program that will calculate and print bills for the city power company.

More information

Chapter 5. Repetition. Contents. Introduction. Three Types of Program Control. Two Types of Repetition. Three Syntax Structures for Looping in C++

Chapter 5. Repetition. Contents. Introduction. Three Types of Program Control. Two Types of Repetition. Three Syntax Structures for Looping in C++ Repetition Contents 1 Repetition 1.1 Introduction 1.2 Three Types of Program Control Chapter 5 Introduction 1.3 Two Types of Repetition 1.4 Three Structures for Looping in C++ 1.5 The while Control Structure

More information

University of Massachusetts Amherst, Electrical and Computer Engineering

University of Massachusetts Amherst, Electrical and Computer Engineering University of Massachusetts Amherst, Electrical and Computer Engineering ECE 122 Midterm Exam 1 Makeup Answer key March 2, 2018 Instructions: Closed book, Calculators allowed; Duration:120 minutes; Write

More information

a) Answer all questions. b) Write your answers in the space provided. c) Show all calculations where applicable.

a) Answer all questions. b) Write your answers in the space provided. c) Show all calculations where applicable. Name: Please fill in your Student Number and Name. Student Number : Student Number: University of Cape Town ~ Department of Computer Science Computer Science 1015F ~ 2008 January Exam Question Max Internal

More information

Midterm Exam CS 251, Intermediate Programming October 8, 2014

Midterm Exam CS 251, Intermediate Programming October 8, 2014 Midterm Exam CS 251, Intermediate Programming October 8, 2014 Name: NetID: Answer all questions in the space provided. Write clearly and legibly, you will not get credit for illegible or incomprehensible

More information

CS 101 Fall 2005 Midterm 2 Name: ID:

CS 101 Fall 2005 Midterm 2 Name:  ID: This exam is open text book but closed-notes, closed-calculator, closed-neighbor, etc. Questions are worth different amounts (in particular, the final two questions are worth substantially more than any

More information

while for do while ! set a counter variable to 0 ! increment it inside the loop (each iteration)

while for do while ! set a counter variable to 0 ! increment it inside the loop (each iteration) Week 7: Advanced Loops while Loops in C++ (review) while (expression) may be a compound (a block: {s) Gaddis: 5.7-12 CS 1428 Fall 2015 Jill Seaman 1 for if expression is true, is executed, repeat equivalent

More information

Week 2. Relational Operators. Block or compound statement. if/else. Branching & Looping. Gaddis: Chapters 4 & 5. CS 5301 Spring 2018.

Week 2. Relational Operators. Block or compound statement. if/else. Branching & Looping. Gaddis: Chapters 4 & 5. CS 5301 Spring 2018. Week 2 Branching & Looping Gaddis: Chapters 4 & 5 CS 5301 Spring 2018 Jill Seaman 1 Relational Operators l relational operators (result is bool): == Equal to (do not use =)!= Not equal to > Greater than

More information

Object Oriented Programming. Java-Lecture 6 - Arrays

Object Oriented Programming. Java-Lecture 6 - Arrays Object Oriented Programming Java-Lecture 6 - Arrays Arrays Arrays are data structures consisting of related data items of the same type In Java arrays are objects -> they are considered reference types

More information

CSCI 136 Data Structures & Advanced Programming. Fall 2018 Instructors Bill Lenhart & Bill Jannen

CSCI 136 Data Structures & Advanced Programming. Fall 2018 Instructors Bill Lenhart & Bill Jannen CSCI 136 Data Structures & Advanced Programming Fall 2018 Instructors Bill Lenhart & Bill Jannen Administrative Details Lab 1 handout is online Prelab (should be completed before lab): Lab 1 design doc

More information

Practice Midterm 1 Answer Key

Practice Midterm 1 Answer Key CS 120 Software Design I Fall 2018 Practice Midterm 1 Answer Key University of Wisconsin - La Crosse Due Date: October 5 NAME: Do not turn the page until instructed to do so. This booklet contains 10 pages

More information

9/19/2018 Programming Data Structures. Polymorphism And Abstract

9/19/2018 Programming Data Structures. Polymorphism And Abstract 9/19/2018 Programming Data Structures Polymorphism And Abstract 1 In-class assignment: deadline noon!! 2 Overview: 4 main concepts in Object-Oriented Encapsulation in Java is a mechanism of wrapping the

More information

Programming with Java

Programming with Java Programming with Java Data Types & Input Statement Lecture 04 First stage Software Engineering Dep. Saman M. Omer 2017-2018 Objectives q By the end of this lecture you should be able to : ü Know rules

More information

EECS168 Exam 3 Review

EECS168 Exam 3 Review EECS168 Exam 3 Review Exam 3 Time: 2pm-2:50pm Monday Nov 5 Closed book, closed notes. Calculators or other electronic devices are not permitted or required. If you are unable to attend an exam for any

More information

AL GHURAIR UNIVERSITY College of Computing. Objectives: Examples: if Single-Selection Statement CSC 209 JAVA I. week 3- Control Statements: Part I

AL GHURAIR UNIVERSITY College of Computing. Objectives: Examples: if Single-Selection Statement CSC 209 JAVA I. week 3- Control Statements: Part I AL GHURAIR UNIVERSITY College of Computing CSC 209 JAVA I week 3- Control Statements: Part I Objectives: To use the if and if...else selection statements to choose among alternative actions. To use the

More information

Final Exam Practice. Partial credit will be awarded.

Final Exam Practice. Partial credit will be awarded. Please note that this problem set is intended for practice, and does not fully represent the entire scope covered in the final exam, neither the range of the types of problems that may be included in the

More information

Check out how to use the random number generator (introduced in section 4.11 of the text) to get a number between 1 and 6 to create the simulation.

Check out how to use the random number generator (introduced in section 4.11 of the text) to get a number between 1 and 6 to create the simulation. Chapter 4 Lab Loops and Files Lab Objectives Be able to convert an algorithm using control structures into Java Be able to write a while loop Be able to write an do-while loop Be able to write a for loop

More information

Arrays. What if you have a 1000 line file? Arrays

Arrays. What if you have a 1000 line file? Arrays Arrays Chapter 8 page 477 11/8/06 CS150 Introduction to Computer Science 1 1 What if you have a 1000 line file? Read in the following file and print out a population graph as shown below. The maximum value

More information

16. Give a detailed algorithm for making a peanut butter and jelly sandwich.

16. Give a detailed algorithm for making a peanut butter and jelly sandwich. COSC120FinalExamReview2010 1. NamethetwotheoreticalmachinesthatCharlesBabbagedeveloped. 2. WhatwastheAntikytheraDevice? 3. Givethecodetodeclareanintegervariablecalledxandthenassignitthe number10. 4. Givethecodetoprintout

More information

Question: Total Points: Score:

Question: Total Points: Score: CS 170 Exam 1 Section 003 Fall 2013 Name (print): Instructions: Keep your eyes on your own paper and do your best to prevent anyone else from seeing your work. Do NOT communicate with anyone other than

More information

CS 101 Fall 2006 Midterm 3 Name: ID:

CS 101 Fall 2006 Midterm 3 Name:  ID: You only need to write your name and e-mail ID on the first page. This exam is CLOSED text book, closed-notes, closed-calculator, closed-neighbor, etc. Questions are worth different amounts, so be sure

More information

B. Subject-specific skills B1. Problem solving skills: Supply the student with the ability to solve different problems related to the topics

B. Subject-specific skills B1. Problem solving skills: Supply the student with the ability to solve different problems related to the topics Zarqa University Faculty: Information Technology Department: Computer Science Course title: Programming LAB 1 (1501111) Instructor: Lecture s time: Semester: Office Hours: Course description: This introductory

More information

Q1 Q2 Q3 Q4 Q5 Total 1 * 7 1 * 5 20 * * Final marks Marks First Question

Q1 Q2 Q3 Q4 Q5 Total 1 * 7 1 * 5 20 * * Final marks Marks First Question Page 1 of 6 Template no.: A Course Name: Computer Programming1 Course ID: Exam Duration: 2 Hours Exam Time: Exam Date: Final Exam 1'st Semester Student no. in the list: Exam pages: Student's Name: Student

More information

Computer Science 210: Data Structures

Computer Science 210: Data Structures Computer Science 210: Data Structures Welcome to Data Structures! Data structures are fundamental building blocks of algorithms and programs Csci 210 is a study of data structures design efficiency implementation

More information

CS 3360 Design and Implementation of Programming Languages. Exam 1

CS 3360 Design and Implementation of Programming Languages. Exam 1 1 Spring 2017 (Thursday, March 9) Name: CS 3360 Design and Implementation of Programming Languages Exam 1 This test has 8 questions and pages numbered 1 through 7. Reminders This test is closed-notes and

More information

University of Utah School of Computing

University of Utah School of Computing University of Utah School of Computing CS 1410 / CS 2000 Study Notes December 10, 2011 This study guide is designed to help you prepare and study the appropriate material for the final exam. For the multiple

More information

CS 61B Data Structures and Programming Methodology. June David Sun

CS 61B Data Structures and Programming Methodology. June David Sun CS 61B Data Structures and Programming Methodology June 25 2008 David Sun Announcements Visit 387 Soda to arrange for after hours access to Soda Hall. Computer Science Undergraduate Association event:

More information

Announcements. 1. Forms to return today after class:

Announcements. 1. Forms to return today after class: Announcements Handouts (3) to pick up 1. Forms to return today after class: Pretest (take during class later) Laptop information form (fill out during class later) Academic honesty form (must sign) 2.

More information

CS 302: Introduction to Programming in Java. Lecture 9

CS 302: Introduction to Programming in Java. Lecture 9 1 CS 302: Introduction to Programming in Java Lecture 9 2 No class on Wednesday in Observance of Fourth of July 3 Announcement Programming Assignment #1 Due 11:59pm Sunday July 8 th Follow style and commenting

More information

Student Performance Q&A:

Student Performance Q&A: Student Performance Q&A: 2004 AP Computer Science A Free-Response Questions The following comments on the 2004 free-response questions for AP Computer Science A were written by the Chief Reader, Chris

More information

Arrays 2 CS 16: Solving Problems with Computers I Lecture #12

Arrays 2 CS 16: Solving Problems with Computers I Lecture #12 Arrays 2 CS 16: Solving Problems with Computers I Lecture #12 Ziad Matni Dept. of Computer Science, UCSB Material: Post- Midterm #1 Lecture 7 thru 12 Homework, Labs, Lectures, Textbook Tuesday, 11/14 in

More information

CS18000: Problem Solving And Object-Oriented Programming

CS18000: Problem Solving And Object-Oriented Programming CS18000: Problem Solving And Object-Oriented Programming Class (and Program) Structure 31 January 2011 Prof. Chris Clifton Classes and Objects Set of real or virtual objects Represent Template in Java

More information

Question: Total Points: Score:

Question: Total Points: Score: CS 170 Exam 1 Section 000 Fall 2014 Name (print): Instructions: Keep your eyes on your own paper and do your best to prevent anyone else from seeing your work. Do NOT communicate with anyone other than

More information

CS446: Machine Learning Fall Problem Set 4. Handed Out: October 17, 2013 Due: October 31 th, w T x i w

CS446: Machine Learning Fall Problem Set 4. Handed Out: October 17, 2013 Due: October 31 th, w T x i w CS446: Machine Learning Fall 2013 Problem Set 4 Handed Out: October 17, 2013 Due: October 31 th, 2013 Feel free to talk to other members of the class in doing the homework. I am more concerned that you

More information

Programming with Arrays Intro to Pointers CS 16: Solving Problems with Computers I Lecture #11

Programming with Arrays Intro to Pointers CS 16: Solving Problems with Computers I Lecture #11 Programming with Arrays Intro to Pointers CS 16: Solving Problems with Computers I Lecture #11 Ziad Matni Dept. of Computer Science, UCSB Thursday, 5/17 in this classroom Starts at 2:00 PM **SHARP** Please

More information

Computer Programming

Computer Programming Computer Programming Dr. Deepak B Phatak Dr. Supratik Chakraborty Department of Computer Science and Engineering Session: while and do while statements in C++ Dr. Deepak B. Phatak & Dr. Supratik Chakraborty,

More information

About this exam review

About this exam review Final Exam Review About this exam review I ve prepared an outline of the material covered in class May not be totally complete! Exam may ask about things that were covered in class but not in this review

More information

Jump Statements. The keyword break and continue are often used in repetition structures to provide additional controls.

Jump Statements. The keyword break and continue are often used in repetition structures to provide additional controls. Jump Statements The keyword break and continue are often used in repetition structures to provide additional controls. break: the loop is terminated right after a break statement is executed. continue:

More information

CS171:Introduction to Computer Science II

CS171:Introduction to Computer Science II CS171:Introduction to Computer Science II Department of Mathematics and Computer Science Li Xiong 1/24/2012 1 Roadmap Lab session Pretest Postmortem Java Review Types, variables, assignments, expressions

More information

Loops and Files. of do-while loop

Loops and Files. of do-while loop L E S S O N S E T 5 Loops and Files PURPOSE PROCEDURE 1. To introduce counter and event controlled loops 2. To work with the while loop 3. To introduce the do-while loop 4. To work with the for loop 5.

More information

CS61BL. Lecture 1: Welcome to CS61BL! Intro to Java and OOP Testing Error-handling

CS61BL. Lecture 1: Welcome to CS61BL! Intro to Java and OOP Testing Error-handling CS61BL Lecture 1: Welcome to CS61BL! Intro to Java and OOP Testing Error-handling About me Name: Edwin Liao Email: edliao@berkeley.edu Office hours: Thursday 3pm - 5pm Friday 11am - 1pm 611 Soda Or by

More information

BCIS 3630 Dr. GUYNES SPRING 2018 TUESDAY SECTION [JAN version] GRADER COURSE WEBSITE

BCIS 3630 Dr. GUYNES SPRING 2018 TUESDAY SECTION [JAN version] GRADER   COURSE WEBSITE COURSE WEBSITE http://www.steveguynes.com/bcis3630/bcis3630/default.html Instructor: Dr. Guynes Office: BLB 312H Phone: (940) 565-3110 Office Hours: By Email Email: steve.guynes@unt.edu TEXTBOOK: Starting

More information

APCS Semester #1 Final Exam Practice Problems

APCS Semester #1 Final Exam Practice Problems Name: Date: Per: AP Computer Science, Mr. Ferraro APCS Semester #1 Final Exam Practice Problems The problems here are to get you thinking about topics we ve visited thus far in preparation for the semester

More information

CS 580 FINAL EXAM. Fall April 29, 2014

CS 580 FINAL EXAM. Fall April 29, 2014 CS 580 FINAL EXAM Fall 201 April 29, 2014 You are to build a range tree for your final exam. A range tree is a tree where each node contains a minimum and a maximum value as well as a linked list to store

More information

Sprint 2017, Sul Ross State University

Sprint 2017, Sul Ross State University Instructor: Dr. Kennard Laviers CS 2360-001 LINUX Sprint 2017, Sul Ross State University Office Location: ACR 107 Office Phone: 432-837-8500 Email: kennard.laviers@sulross.edu Office Hours: MW 8:30am -

More information

An array is a collection of data that holds fixed number of values of same type. It is also known as a set. An array is a data type.

An array is a collection of data that holds fixed number of values of same type. It is also known as a set. An array is a data type. Data Structures Introduction An array is a collection of data that holds fixed number of values of same type. It is also known as a set. An array is a data type. Representation of a large number of homogeneous

More information

Mathematics/Science Department Kirkwood Community College. Course Syllabus. Computer Science CSC142 1/10

Mathematics/Science Department Kirkwood Community College. Course Syllabus. Computer Science CSC142 1/10 Mathematics/Science Department Kirkwood Community College Course Syllabus Computer Science CSC142 Bob Driggs Dean Cate Sheller Instructor 1/10 Computer Science (CSC142) Course Description Introduces computer

More information

CSCI 136 Data Structures & Advanced Programming. Fall 2018 Instructors Bill Lenhart & Bill Jannen

CSCI 136 Data Structures & Advanced Programming. Fall 2018 Instructors Bill Lenhart & Bill Jannen CSCI 136 Data Structures & Advanced Programming Fall 2018 Instructors Bill Lenhart & Bill Jannen Administrative Details Class roster: Who s here? And who s trying to get in? Handout: Class syllabus Lecture

More information

Lecture 10. Daily Puzzle

Lecture 10. Daily Puzzle Lecture 10 Daily Puzzle Imagine there is a ditch, 10 feet wide, which is far too wide to jump. Using only eight narrow planks, each no more than 9 feet long, construct a bridge across the ditch. Daily

More information

Programming in Java Prof. Debasis Samanta Department of Computer Science Engineering Indian Institute of Technology, Kharagpur

Programming in Java Prof. Debasis Samanta Department of Computer Science Engineering Indian Institute of Technology, Kharagpur Programming in Java Prof. Debasis Samanta Department of Computer Science Engineering Indian Institute of Technology, Kharagpur Lecture 04 Demonstration 1 So, we have learned about how to run Java programs

More information

ECSE 321 Assignment 2

ECSE 321 Assignment 2 ECSE 321 Assignment 2 Instructions: This assignment is worth a total of 40 marks. The assignment is due by noon (12pm) on Friday, April 5th 2013. The preferred method of submission is to submit a written

More information

FORM 2 (Please put your name and form # on the scantron!!!!)

FORM 2 (Please put your name and form # on the scantron!!!!) CS 161 Exam 2: FORM 2 (Please put your name and form # on the scantron!!!!) True (A)/False(B) (2 pts each): 1. Recursive algorithms tend to be less efficient than iterative algorithms. 2. A recursive function

More information

Programming for Engineers Iteration

Programming for Engineers Iteration Programming for Engineers Iteration ICEN 200 Spring 2018 Prof. Dola Saha 1 Data type conversions Grade average example,-./0 class average = 23450-67 893/0298 Grade and number of students can be integers

More information

CS162 Computer Science I Fall 2018 Practice Exam 1 DRAFT (9 Oct.)

CS162 Computer Science I Fall 2018 Practice Exam 1 DRAFT (9 Oct.) Name: CS162 Computer Science I Fall 2018 Practice Exam 1 DRAFT (9 Oct.) The real test will look much like this one, but it will be shorter. I suggest taking this practice test under real conditions (closed

More information

CS 216 Exam 1 Fall SOLUTION

CS 216 Exam 1 Fall SOLUTION CS 216 Exam 1 Fall 2004 - SOLUTION Name: Lab Section: Email Address: Student ID # This exam is closed note, closed book. You will have an hour and fifty minutes total to complete the exam. You may NOT

More information

5/23/2015. Core Java Syllabus. VikRam ShaRma

5/23/2015. Core Java Syllabus. VikRam ShaRma 5/23/2015 Core Java Syllabus VikRam ShaRma Basic Concepts of Core Java 1 Introduction to Java 1.1 Need of java i.e. History 1.2 What is java? 1.3 Java Buzzwords 1.4 JDK JRE JVM JIT - Java Compiler 1.5

More information

More Flow Control Functions in C++ CS 16: Solving Problems with Computers I Lecture #4

More Flow Control Functions in C++ CS 16: Solving Problems with Computers I Lecture #4 More Flow Control Functions in C++ CS 16: Solving Problems with Computers I Lecture #4 Ziad Matni Dept. of Computer Science, UCSB Administrative CHANGED T.A. OFFICE/OPEN LAB HOURS! Thursday, 10 AM 12 PM

More information