Assignment 6: Array gymnastics

The goal of this assignment is for you to develop a good facility with loops and arrays. Arrays are a tremendously important part of programming, so it’s worth investing some real time and effort into getting good at them.

For this reason, this assignment is a little longer than usual. However, your OWL is shorter this week, and I did not give you the lab exercises to do as I had been planning.

I strongly recommend that you first experiment with arrays.  For example, create a small array of 3 integers, fill the array, output the array, calculate the average of the array, etc.  Create other kinds of arrays and experiment with them a little as well. Once you get the basics down, I think you’ll see that the assignment is not terribly difficult. But you will have to be fairly comfortable with basic array behavior to get there.

DO NOT procrastinate on this assignment. Arrays are just too important! So invest the time now!

This assignment has three required parts and there are a few extra credit opportunities.  All required parts must be completed for full credit.  This is an individual assignment.

Your final submission will be a zip file containing:

·         The file containing the array exercises

·         Your algorithm for the gymnastics assignment

·         The gymanstics source code file

·         The ‘How Was It?’ file

Important:  EVERY time you iterate through an array (e.g. inputting values, outputting values, determining averages, etc), you must use a for-loop.

Part 1: Array exercises

In a class called ‘ArrayPractice’  write code to do the following:

1.      (10 points) Create an array of 3 strings. Prompt the user to enter 3 strings. Then output:

a.       The length of the longest string

b.      The length of the shortest string

c.       Bonus (3 points): The total number of times that the letter ‘e’ (upper or lower case) is present in the array of strings.

2.      (15 points) Create an array of 100 integers.  Fill the array with random numbers between 1 and 6 to represent a simulated roll of a dice (or is it “die”??  – I never know).  Then output the number all of the values with a space in between each.  Then output the number of times the number 1 was “rolled”, the number 2 was “rolled”, through number 6.

a.       Bonus 5 points:  Create a graph that prints out a star (‘ * ‘) for each such as in the example below. Obviously the total number of stars should be 100.

1:  ****************

2: ********************************

3: *********

4: ***************

5: *************************************

6: *********************

Part 2: Array gymnastics

The final phase of a gymnastics competition has three athletes competing for the gold medal.  Eight judges give scores after each contestant's performance.  Scores are numbers from 1 to 10 and do not have to be integers.  For example, 8.5 is an acceptable score.  The highest and lowest scores are discarded.  The remaining 6 scores are summed and the total is the assigned final score for the contestant.  The contestant with the highest score earns the gold medal.

(10 points) Write a detailed JEnglish description of how you will solve the problem.  You should include descriptions of how to read in the names of each contestant, read in the scores for each contestant, compute the final scores for each contestant, and determine who wins the gold.  The description should be detailed enough to serve as your guide when creating the program but should not include any valid Java statements.  Place this in a text document and attach it to your assignment.

Your program must satisfy the following requirements:

1. Greet the user with a welcome message.
2. (5 points) Get the names of the three contestants and store them into an array.  Using an array is required.  What will be the type of the array?
3. For each of the three contestants:
1. (10 points) Ask for and collect the scores of the eight judges.  (Note: see the second bonus option at this point.  You’ll almost certainly want to do that part – it’s not that hard, it’s bonus points, and it will save you lots of time during testing).  Display a personalized prompt before getting the scores, such as "Please enter the scores for Natalia." if Natalia is the name of the athlete for whom you are gathering scores.  You are required to store the scores for each athlete in an array.  What will be the type of the array?
2. (15 points) Compute the final score by dropping the highest and the lowest and summing the remaining 6 scores.
4. (10 points) Determine the winner of the gold medal.  If there is a tie, indicate that.
5. (10 points) Announce the winner of the gold medal and the final scores for each of the three athletes.  Personalize the message to use the name of the athletes when displaying the winner and the scores.

Part 3: How was it?

(5 points) Create a short ReadMe Word or text file (ReadMe.doc or ReadMe.txt) containing the following information: