COSI 11a Chapter Notes - Chapter 5: Texas State Highway Loop 1, Operand, Institute For Operations Research And The Management Sciences

80 views2 pages
Chapter 5 Outline
Program Logic and Indefinite Loops
Pages 301 372
I. The while Loop
A. Random Numbers
1. Math.random() can be used to obtain a number between 0 and 1, including 0 but not including
1.
2. The java.util package contains a random class with methods nextInt(), nextInt(max),
nextDouble(), and nextBoolean(). The nextInt method is passed a maximum number from which
0 (inclusive) to max (exclusive) the random number is chosen. To use the random class, a
random object must be created:
Random r = new Random();
B. do/while Loop
1. do/while loops are useful when you have to execute a loop at least once.
II. The Boolean Type
A. Logical Operators
1. The NOT operator (!) reverses the value of the operand, such as !(2==2) resulting in false.
III. User Errors
A. Scanner Lookahead
1. Every next method in the Scanner class has a corresponding has method.
2. The has method of the Scanner class informs the user whether or not the operation can be
performed.
find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows half of the first page of the document.
Unlock all 2 pages and 3 million more documents.

Already have an account? Log in

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents