CSIS 110 Lecture 15: Quiz Results and Discussion on Loops and Iteration in Java - Prof. Br, Study notes of Javascript programming

The results of a quiz on csis 110 lecture 15, focusing on statistics related to the quiz and a discussion on java loops and iteration. Topics include understanding the mean, standard deviation, median, and distribution of quiz scores, as well as examples of while loops and their memory usage. The document also covers infinite loops and shorthand operators in java.

Typology: Study notes

Pre 2010

Uploaded on 08/05/2009

koofers-user-f8a-1
koofers-user-f8a-1 🇺🇸

5

(1)

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CSIS 110 – Lecture 15
Quiz Results
Statistics
Possible: 25
Mean: 16.9
Std dev: 4.8
Median: 18
Max: 23
Distribution: <=15: 3, 15 to 19: 6, 20+: 4
Let's look at examples from the last lab
Chapter 6: Iteration
Last time we looked at the while statement.
while ( <boolean expression> )
statement
And we looked at a couple of programs that included the while statement:
NumberAverage.java and Interest.java.
Flow chart.
Let's look at memory as this loop executes
Remember, main steps of the loop:
preparation
while situation of interest is true {
loop processing
prepare for next iteration
}
What are the values of variables after the loop executes?
Infinite loops: if you don't modify the values of the variables used in the boolean
expression correctly, your loop will never stop.
while ( number > 0 ) {
sum = sum + number;
pf2

Partial preview of the text

Download CSIS 110 Lecture 15: Quiz Results and Discussion on Loops and Iteration in Java - Prof. Br and more Study notes Javascript programming in PDF only on Docsity!

CSIS 110 – Lecture 15

Quiz Results Statistics Possible: 25 Mean: 16. Std dev: 4. Median: 18 Max: 23 Distribution: <=15: 3, 15 to 19: 6, 20+: 4 Let's look at examples from the last lab Chapter 6: Iteration Last time we looked at the while statement. while ( ) statement And we looked at a couple of programs that included the while statement: NumberAverage.java and Interest.java. Flow chart. Let's look at memory as this loop executes Remember, main steps of the loop: preparation while situation of interest is true { loop processing prepare for next iteration } What are the values of variables after the loop executes? Infinite loops: if you don't modify the values of the variables used in the boolean expression correctly, your loop will never stop. while ( number > 0 ) { sum = sum + number;

System.out.println( sum ); NOTE: When might you want a loop to run "forever"? Beware of the same types of errors that occur with if statements: don't put a ; after the boolean expression. Don't forget the {} *Operators +=, -=, =, /=, %= In our programs, we frequently use a variable, add a value to it, and assign the result back into the original variable: valueSum = valueSum + value; money = money * (1 + interest); This is a very common type of expression, so Java provides a shorthand operator for us valueSum += value; money = 1 + interest; // Also /=, -=, %= String s = ""; int j = 0; while ( j < 20 ) { s += ""; j++; } Lab Exercise In genetics, DNA is represented using the symbols A, G, T, and C. Develop a program that asks the user to enter a DNA sequence. Your program should display one of two messages: "That String represents a DNA sequence" "That is not a DNA sequence. The character at position is not one of A, G, T, or C." Your program may stop after it finds the first invalid character.