Homework #6 – Due Tuesday
Because each problem in this assignment is done inside a method, this assignment requires you to create only ONE class.
In ALL cases, when asked to iterate through an array (output the values, do calculations, etc), you MUST use a for loop.
1. Create a method called problem1(). Inside this method, declare an array of 5 Strings. Assign each element of the array a string of your choice. Output each String in the array. Also output the length of each String. So if your array begins with strings “Marc, Bob, Hello….” You would output Marc 4, then Bob 3, then Hello 5, etc. You do NOT need to prompt the user for the 5 strings. You can simply hard-code them directly into the array. This will save you a bunch of typing as you test.
2. Create a method called problem2(). Inside this method, create an array of 5 integers. Fill the array with any integer values you like. Using your loop, calculate the highest value, lowest value, and average of all the numbers in the array.
3. Create a method called problem3(). Inside this method, create an array of 100 integers. Fill the array with random numbers between 1 and 6. Then ask the user to pick a number between 1 and 6. Output the number of times that number is present in the array. So if the user picks ‘5’, you will tell them how many 5s are present in the array.
Submit this entire assignment as a single source code file. You should only have one source code file since everything takes place inside methods. You do NOT have to zip it.