Question

What is the easiest way to code this? Write a program GymnasticScores.java that reads in seven...

What is the easiest way to code this?

Write a program GymnasticScores.java that reads in seven gymnastics scores from the judges. Compute a final score based on the individual scores. Because of the judging biases, the highest and lowest scores must not be included in the average. Compute the average of the remaining five scores and print it out to 2 significant digits. Two example runs are shown below.

9.2
4.3
6.0
8.7
7.3
8.0
9.1
Average score: 7.82
5.0
9.1
6.8
4.777
10.0
2.258
9.0
Average score: 6.94
0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.*;

import java.text.DecimalFormat;

class GymnasticScores {

public static void main(String[] args) {

double scores[]=new double[7];

double high=0,low,sum=0,avg;

Scanner sc=new Scanner(System.in);

for(int i=0;i<7;i++){

scores[i]=sc.nextDouble();

}

low=scores[0];

for(int i=0;i<7;i++){

sum+=scores[i];

if(scores[i]>high)

high=scores[i];

if(scores[i]<low)

low=scores[i];

}

avg=(sum-low-high)/5;

DecimalFormat df = new DecimalFormat();

df.setMaximumFractionDigits(2);

System.out.println("Average is : "+df.format(avg));


}

}

if you like the answer please provide a thumbs up.

Add a comment
Know the answer?
Add Answer to:
What is the easiest way to code this? Write a program GymnasticScores.java that reads in seven...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • A particular talent competition has five judges, each of whom awards a score between 0 and...

    A particular talent competition has five judges, each of whom awards a score between 0 and 10 to each performer. Fractional scores, such as 8.3, are allowed. A performer’s final score is determined by dropping the highest and the lowest score received then averaging the three remaining scores. Write a program that does the following: 1. Reads names and scores from an input file into a dynamically allocated array of structures. The first number in the input file represents the...

  • ***C++ Code*** What this Assignment Is About: -Learn to define and call void & non-void functions...

    ***C++ Code*** What this Assignment Is About: -Learn to define and call void & non-void functions -Learn to use reference variables Coding Guidelines for All Labs/Assignments (You will be graded on this) -Give identifiers semantic meaning and make them easy to read (examples numStudents, grossPay, etc). -Keep identifiers to a reasonably short length. -Use upper case for constants. Use title case (first letter is upper case) for classes. Use lower case with uppercase word separators for all other identifiers (variables,...

  • STATISTICS HYPOTHESIS It appears that not all people are equally vulnerable to cancer. People from some...

    STATISTICS HYPOTHESIS It appears that not all people are equally vulnerable to cancer. People from some ethnic groups have higher or lower than average chances of developing certain types of cancer. Jennifer's manager Dr. Steinberg thinks that the company's insurance policy should reflect this fact and constantly raises this question in the meetings. To be more convincing, he asked Jennifer Nguyen to take a random sample of those Healthy Life clients who belong to ethnic group X (at least on...

  • • 1. What are the quarterly growth rates (Percentage Change From Preceding Period in Real Gross...

    • 1. What are the quarterly growth rates (Percentage Change From Preceding Period in Real Gross Domestic Product) for the U.S. economy for the last six quarters? Report those numbers in your submission 2. What is the average of those 6 quarters? . 3. Is the average of those growth rates above or below the long-run U.S. annual growth rate of 3.5 percent? Bureau of Economke Analysis Table 1.1.1. Percent Change From Preceding Period in Real Gross Domestic Product Percent...

  • 4.3 Analysis Assignment #4 Note 1: all assignments moving forward must adhere to the appropriate Six Ste...

    4.3 Analysis Assignment #4 Note 1: all assignments moving forward must adhere to the appropriate Six Step Process (SSP). As our study materials have specified, the SSP has 3 versions. Version 1 is to be used for all t-tests; for all correlation analyses and Version 3 is be used for all regression analyses. Note 2: The data sets for Q1, Q2 and Q3 below can be downloaded here. Week 4 Analysis Assignments.xlsx Q1: (30 points) Complete the following data analysis:...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
Active Questions
ADVERTISEMENT