Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Operators and the Web Log Analyzers - Study Guide | CSIS 110, Study notes of Javascript programming

Material Type: Notes; Professor: Hanks; Class: Intro to Programming in Java; Subject: Computer Science Info Systems; University: Fort Lewis College; Term: Winter 2005;

Typology: Study notes

Pre 2010

Uploaded on 08/05/2009

koofers-user-s6c
koofers-user-s6c 🇺🇸

10 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CSIS 110 - Lecture 11
Announcements:
Homework on course web site – due Friday
Programming assignment due next Monday
Reading: 4.1 to 4.6 (pp 79-86)
Discuss appropriate indenting – if statements, for loops, blocks
- Always indent
- Always indent by the same amount
- Closing brace in correct column
Last Time:
Arrays
- what is an array?
- How do we declare an array variable?
- How do we allocate the array elements?
- How do we access an individual element?
For Loops
A for loop allows us to execute a sequence of statements sequentially. An example:
for ( int i = 5; i < 30; i = i + 7 ) {
System.out.print( i + " " );
}
What are the parts of the for statement? [Draw Flowchart]
What does this for loop do?
How would we calculate the average of the values contained in an array?
[discuss integer division. Introduce the type double]
Operators +=, -=, *=, /=, %=
In our programs, we frequently use a variable, add a value to it, and assign the result back
into the original variable
sum = sum + theArray[i];
balance = balance + salesTax;
This is a very common type of expression, so Java provides a shorthand operator for us
pf3

Partial preview of the text

Download Operators and the Web Log Analyzers - Study Guide | CSIS 110 and more Study notes Javascript programming in PDF only on Docsity!

CSIS 110 - Lecture 11

Announcements: Homework on course web site – due Friday Programming assignment due next Monday Reading: 4.1 to 4.6 (pp 79-86) Discuss appropriate indenting – if statements, for loops, blocks

  • Always indent
  • Always indent by the same amount
  • Closing brace in correct column Last Time: Arrays
  • what is an array?
  • How do we declare an array variable?
  • How do we allocate the array elements?
  • How do we access an individual element? For Loops A for loop allows us to execute a sequence of statements sequentially. An example: for ( int i = 5; i < 30; i = i + 7 ) { System.out.print( i + " " ); } What are the parts of the for statement? [Draw Flowchart] What does this for loop do? How would we calculate the average of the values contained in an array? [discuss integer division. Introduce the type double] *Operators +=, -=, =, /=, %= In our programs, we frequently use a variable, add a value to it, and assign the result back into the original variable sum = sum + theArray[i]; balance = balance + salesTax; This is a very common type of expression, so Java provides a shorthand operator for us

sum += theArray[i]; balance += salesTax; // Also =, /=, -=, %= Can do this with String concatenation also: String s = ""; for ( int = 0; j < 20; j++ ) { s += ""; } Web-Log analyzer Let's look at the web-analyzer project. This project is supposed to be a very simple version of a web-site traffic analyzer. Web sites keep a record of all the pages that have been accessed, and then the owners can analyze the data to look for trends. This class examines files where each line in the file represents an access to the web site. Each line in the file contains five numbers: year month day hour minute. For example: 2005 06 23 03 17. Look at LogAnalyzer class. Where is the array declared? Where is it allocated? Right now, the Analyzer class only uses the hour value from the log files. It has methods to count the number of access that occur in each hour, and print out those numbers. Let's look at the methods. What do they do? Mention while loop. Discuss abstraction again – we're using some methods in LogReader and LogEntry classes. Discuss the statement hourCounts[hour]++;