Presentation is loading. Please wait.

Presentation is loading. Please wait.

Day 26 Arrays Episode 2. Array Lengths To determine the length of an array, use the command: array_Name.length.

Similar presentations


Presentation on theme: "Day 26 Arrays Episode 2. Array Lengths To determine the length of an array, use the command: array_Name.length."— Presentation transcript:

1 Day 26 Arrays Episode 2

2 Array Lengths To determine the length of an array, use the command: array_Name.length

3 Array Lengths Exercise: given the following array, write a for loop that prints out each of its values using the length command. int[] studentIDs = new int[10];

4 Array Lengths int[] studentIDs = new int[10]; Solution: for (int i = 0; i < studentIDs.length; i++) { System.out.println(studentIDs[i]); }

5 Do the following step by step Exercise: 1) Write a program that reads n number of temperatures from the keyboard. The number n is specified by the keyboard as well. 2) The code should output the average temperature. 3) The code should output all the temperatures above the average and all the temperatures below the average (with professional print statements).

6 Exercise #3 Print out every third temperature using a for loop.

7 Exercise #4 – To code or not to code? That is the Question. Something you should be aware of, but should not do, is to save each failed password attempt. Why is it wrong to do? Is it probable that the attempted passwords reveal user has for other accounts? Why is it right to do? Does it show what category most people fail to satisfy (symbols, nums, caps..)

8 Exercise #4 – To code or not to code? That is the Question. Modify your code (assignment #3 – pswd.java) to save the first three failed passwords in an array. Print out the failed passwords

9 Work on Assignment #2


Download ppt "Day 26 Arrays Episode 2. Array Lengths To determine the length of an array, use the command: array_Name.length."

Similar presentations


Ads by Google