16-mar31

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

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

View Full Document Right Arrow Icon
1 COMP 110 Arrays Tabitha Peck M.S. March 31, 2008 MWF 3-3:50 pm Philips 367
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 Announcements Program 4 assigned Wednesday Program 3 grades done! (Sorry so late)
Background image of page 2
3 Questions?
Background image of page 3

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

View Full DocumentRight Arrow Icon
4 Today in COMP 110 Arrays
Background image of page 4
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(); }
Background image of page 5

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

View Full DocumentRight Arrow Icon
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]
Background image of page 6
7 Indexing Starts at ZERO
Background image of page 7

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

View Full DocumentRight Arrow Icon
Background image of page 8
Background image of page 9

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

View Full DocumentRight Arrow Icon
Background image of page 10
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

This note was uploaded on 02/02/2009 for the course COMP 110 taught by Professor Stotts during the Spring '08 term at UNC.

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 Right Arrow Icon
Ask a homework question - tutors are online