Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Computer Programming

Similar presentations


Presentation on theme: "Introduction to Computer Programming"— Presentation transcript:

1 Introduction to Computer Programming
CS 126 Lecture 8 Zeke Maier

2 Plan for Today Questions Administrivia AD Exercises 4.2 & 4.3
Developing Debugging Compound Data Assignment

3 Questions

4 Administrivia http://students.cec.wustl.edu/~ejm3/
Help Session 2-4 in Sever 201 No office hours Quiz 1 Solutions Lab 1 Demo Results Remote Desktop TA Schedule?

5 AD Exercises 4.2 & 4.3 If you are given three sticks, you may or may not be able to arrange Exercise 4.2 them in a triangle. For example, if one of the sticks is 12 inches long and the other two are one inch long, it is clear that you will not be able to get the short sticks to meet in the middle. For any three lengths, there is a simple test to see if it is possible to form a triangle: “If any of the three lengths is greater than the sum of the other two, then you cannot form a triangle. Otherwise, you can.” Write a method named isTriangle that it takes three integers as arguments, and that returns either true or false, depending on whether you can or cannot form a triangle from sticks with the given lengths. The point of this exercise is to use conditional statements to write a method that returns a value. a. Write the number 1 next to the first statement of this program that will be executed. Be careful to distinguish things that are statements from things that are not. b. Write the number 2 next to the second statement, and so on until the end of the program. If a statement is executed more than once, it might end up with more than one number next to it. c. What is the value of the parameter blimp when baffle gets invoked? d. What is the output of this program?

6 Developing Development Plan Development Plan Write a method Write more
Compile Fix syntax errors Fix semantic errors Development Plan Start with a work program Write a small logical block Compile & test Fix errors the only solution is to remove code until you have a working program again, and then gradually build the program back up. -After every change we can see something visible * If error than we know the error is in the small logical block AD gives a drawn out example of writing an isIn function. I don’t expect quite as much checking as he does, but some is good!

7 Debugging Determine which type the error is Compiler Errors
Tricks: * Project->Build Automatically – forces eclipse to recompile the Java code every time you save. When I code its second nature to hit CTRL->S at the end of a logical block/thought to save and get a compilation * CTRL + SHIFT + F to format a file * Breakpoints! Always debug the first error first! Error messages can be hard to understand, but normally there is useful information lurking inside

8 Compound Data

9 Assignments Lab 2 due Wednesday Readings Monday KG Notes


Download ppt "Introduction to Computer Programming"

Similar presentations


Ads by Google