65-lecture12 - Computer Science 65 Intro to CS March 4,...

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

View Full Document Right Arrow Icon
Computer Science 65 Intro to CS March 4, 2008 Methods (Chapter 5.1 – 5.2) Exam Review
Background image of page 1

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

View Full DocumentRight Arrow Icon
Announcements Exam #1, Thursday March 6 th Study Guide is online Covers Chapter 1 through material today (Chapter 5.2) You can bring in 1 sheet of notes
Background image of page 2
Chapter 5 Methods Methods are a collection of statements that performs a specific task You have created a main method in every program you’ve written You have executed predefined methods such as System.out.println Integer.parseInt
Background image of page 3

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

View Full DocumentRight Arrow Icon
2 Different Kinds of Methods A void method is one that simply performs a task and then terminates. System.out.println("Hi!"); A value-returning method not only performs a task, but also sends a value back to the code that called it. int number = Integer.parseInt( " 700 " );
Background image of page 4
Method Execution Transfer
Background image of page 5

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

View Full DocumentRight Arrow Icon
Try It! Program generates a random number between 0 and 9 if the number is <5 print “You Lose” If the number is >= 5 print “You Win” Create two new void methods displayWin Print “You Win” displayLose Print “You Lose”
Background image of page 6
import java.util.Random;
Background image of page 7

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

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

This note was uploaded on 04/02/2008 for the course CS 065 taught by Professor Urness during the Spring '08 term at Drake University .

Page1 / 13

65-lecture12 - Computer Science 65 Intro to CS March 4,...

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

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