week-03-handout

week-03-handout - 1 COMP 202 Introduction to Computing 1...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1 COMP 202 Introduction to Computing 1 COMP 202 - Week 3 1 COMP 202 Week 3 Learning outcomes : More practice on arithmetic expressions How to use String in your program How to take user input Introduce some built-in library facilities in Java How to use Objects and Methods COMP 202 Introduction to Computing 1 COMP 202 - Week 3 2 Announcement Midterm Exam Time: October 26, Thursday, 6pm- 8pm Venue: Section- 2: LEA-219 COMP 202 Introduction to Computing 1 COMP 202 - Week 3 3 Review How many of you have successfully written and executed your first program in Java? Assignments The program for calculating travel time Tips on debugging a program 2 COMP 202 Introduction to Computing 1 COMP 202 - Week 3 4 Review programming exercise Problem: How should I go to school every day? By train or by car? I will take whichever is faster. My home is in west island. I know the total distance is 25 km if I drive from home. 20 km of it is in Autoroutes/highways. I can go upto 80 km/hr in those highways. But inside downtown, during the rush-hours, I have to stop 3 minutes in every intersections, and I have to cross 5 intersection on my way. Also I can drive only 40km/hr. Moreover, once I reach near McGill, I need to spend another 15 minutes to look for a free parking space. No, this is ridiculous! I would better come by train. The train takes 15 minutes to travel from my home station to McGill station. I know I can walk 5km/hr. My home train station is 500 meters from my home. And, my classroom is 1km from the McGill train station. Can a computer program help me decide? What happens if my sister is taller than me and walks 5.5 km/hr? What happens if my dad want to come to my school? He walks slower than me, 4 km/hr. What if my brother drives 100km/hr in the highway and 50km/hr in the city? COMP 202 Introduction to Computing 1 COMP 202 - Week 3 5 Write and execute program Write the program source code in your favorite plain text editor Save the code in a file named SomeThing.java Compile the java source code file using javac SomeThing.java It will create one or more class files Execute the main class using java MainClassName COMP 202 Introduction to Computing 1 COMP 202 - Week 3 6 Debugging (review) Common Syntax errors Missing semicolon Missing parenthesis or braces Misspelling identifiers Use extra println() to see the intermediate results, if they give expected value Use debugging tools from an IDE Sometimes Debugging is like a scientific experiment Set some check-points in the middle of the program Verify the values of some variables 3 COMP 202 Introduction to Computing 1 COMP 202 - Week 3 7 Assignment, Expressions and Statements (revisited) Reading and writing variables Left and the right side of assignment = Expression vs statement Specials about shortcut operators a++ and ++a COMP 202 Introduction to Computing 1...
View Full Document

Page1 / 19

week-03-handout - 1 COMP 202 Introduction to Computing 1...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online