Assignment #7

 

Problem #1

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.

 

 Your program must satisfy the following requirements:

·         Greet the user with a welcome message.  Place this inside a method called ‘greetUser’

·         Get the names of the three contestants. These names should be stored inside an array of Strings.

 

For each of the three contestants:

·         Ask for and collect the scores of the eight judges.  (Generate random numbers for this part – I’m sure you don’t want to have to enter 8 values for each user each time you test!).  Experiment with and modify the Math.random() method you have been using to get a number (double) between 1.0 and 10.0.  You will see lots of decimal places, but that’s okay.  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?

·         Compute the final score by dropping the highest and the lowest and summing the remaining 6 scores.

·         Determine the winner of the gold medal.  If there is a tie, indicate that.

·         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.

 

Note that you will require more than one array for this problem.

 

Problem #2

Create an array of 100 integers representing a roll of a 6-sided die. Fill the array with random numbers between 1 and 6. Then output the number of times each value was rolled.

For example:

1s:   14

2s:   11

Etc

6s:  17

 

Then output using a graph with an asterisk for each time the number was rolled. So if the number 1 was rolled 14 times, and the number 2 was rolled 11 times, it would look something like this:

1s: **************

2s:  ***********

Etc

Etc

6s: *****************