Java Bootcamp Resources ->
Module 1 ->
6. Arrays, open Workbook 6.5.
You and your friends are playing Pac-Man. The one with the highest score wins a prize.
Make a function that returns a random number between 0 and 50,000.
/** * Function name -- randomNumber * * @return random number (int) * * Inside the function * - return a random number * */
Create an array that stores 10 random numbers. Using a
for loop, print the contents of the array:
Here are the scores: 14775 48328 7928 27102 21787 21063 38096 42711 32863 23707
Print every element on the same line.
Leave one space between each element.
There is a variable
highScore that starts at 0.
forloop, find the highest score in the array and update
\n\nThe highest score is: <highScore>. Give that man a cookie!
Loop through every value in the array.
Inside the loop, check if the current element is higher than the high score. If so, update the high score.