{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

16-mar31

# 16-mar31 - • Index can be called with – Integer score[3...

This preview shows pages 1–10. Sign up to view the full content.

1 COMP 110 Arrays Tabitha Peck M.S. March 31, 2008 MWF 3-3:50 pm Philips 367

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

View Full Document
2 Announcements Program 4 assigned Wednesday Program 3 grades done! (Sorry so late)
3 Questions?

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

View Full Document
4 Today in COMP 110 Arrays
5 Remember… while (inputScore >= 0) { games++; //increment number of games scoreSum += inputScore; if (inputScore >= 90) { gamesOver90++; scoreSum90 += inputScore; } if (inputScore < lowest) lowest = inputScore; if (inputScore > highest) highest = inputScore; System.out.println( "Please input a score (-1 to signal you are done)" ); inputScore = keyboard.nextInt(); }

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

View Full Document
6 Arrays A collection of variables of the same type int[] score = new int[5]; 5 variables of type int named score[0], score[1], score[2], score[3], score[4]
7 Indexing Starts at

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

View Full Document

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: • Index can be called with – Integer score[3] – Variable (of type int) score[index] – Expression (evaluates to int) score[index*3] • Index must be in range – int score = new int[5] – Index from 0 to 4 8 Visualizing an array 1 2 3 4 5 6 7 8 9 80 89 92 78 86 90 76 91 83 90 score[4] Base_Type Array_Name = new Base_Type [ Length ] score.length = 10 9 Using Arrays • You have an array, score • Total number of games: • Total number of games scoring at least 90 points: • Percentage of games scoring at least 90 points: • Average game score: • Range of scores: lowest to highest 10 Wednesday • More with arrays • Read 6.2...
View Full Document

{[ snackBarMessage ]}

### Page1 / 10

16-mar31 - • Index can be called with – Integer score[3...

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

View Full Document
Ask a homework question - tutors are online