Download presentation
Presentation is loading. Please wait.
1
1 COMP 110 Arrays Tabitha Peck M.S. March 31, 2008 MWF 3-3:50 pm Philips 367
2
2 Announcements Program 4 assigned Wednesday Program 3 grades done! (Sorry so late)
3
3 Questions?
4
4 Today in COMP 110 Arrays
5
5 Remember… while(inputScore >= 0) { games++; //increment number of games scoreSum += inputScore; if (inputScore >= 90) { gamesOver90++; scoreSum90 += inputScore; } if (inputScore highest) highest = inputScore; System.out.println("Please input a score (-1 to signal you are done)"); inputScore = keyboard.nextInt(); }
6
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
7 Indexing Starts at ZERO Index can be called with –Integer scores[3] –Variable (of type int) scores[index] –Expression (evaluates to int) scores[index*3] Index must be in range –int[] score = new int[5] –Index from 0 to 4
8
8 Visualizing an array 0123456789 80899278869076918390 score[4] Base_Type[] Array_Name = new Base_Type[Length] score.length = 10
9
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
10 Wednesday More with arrays Read 6.2
Similar presentations
© 2025 SlidePlayer.com Inc.
All rights reserved.