|
Array Activities in HWJ15_Arrays
In a method public void practiceArrayInts() do the following:
- Create an array size 10 of integers.
- Have it have the values 10,20,30,40,50 and so on.
- Print out all the numbers in the array.
- Find the sum of all the numbers in the array and print that out.//use a for loop
- Add 7 to every number in the array. //use a for loop
- [advanced] Print out the remainder when every number in the array is divided
by 7.//use a for loop
- [advanced] Replace all values with random ints numbers between 1 and 100 and print it out
- [super adv] Sort the array
NOT HOMEWORK TONIGHT
In a method public void practiceArrayStrings() do the following: (
- Create an array with 3 names.
- Have it print out every name on its own line.
- Have it print out the length of each name ( ie Jeff -> 4
letters
- [advanced] Have it say how many times the letter e is in each name (ie Jeff->
1 e) [hard, extra credit]
- Have it replace all the a and e with z.
- Have it print it out.
- [advanced]Have it say which word comes first alphabetically (use compareTo)
[hard, extra credit)
- [advanced] Have it reorder the words alphabetically
|