1) Apply the problem-solving process from initial problem analysis through code
ID: 3716703 • Letter: 1
Question
1) Apply the problem-solving process from initial problem analysis through code testing 2) Use decomposition to identify main tasks, and determine the correct sequence for the tasks in order to solve the problem 3) Practice using keyboard input to fill arrays 4) Practice using loops to process data in arrays using common algorithms Description: The topic of this programming assignment is determining the gold-medal winner of a half-pipe snowboarding competition, based on scores that are examples of actual data compiled and analyzed during the recent winter Olympic Games in South Korea. The name of all snowboarders and scores earned for one run are saved in a data file. A snowboarder’s halfpipe run is scored as follows: • A team of six judges scores each halfpipe run. In the actual games, competitors had three runs to try to earn their very highest possible score. However, for this lab, the data for each snowboarder will reflect just their highest score, regardless on which run it occurred. • Each judge gives a subjective score from 1 to 100 based on overall impression, composed of height maintained throughout the run; variety and difficulty of maneuvers; and execution skill. (The six individual scores are not publicized, so we will have to make an assumption on data type.) • The highest and lowest scores of the six judges are dropped for the run. • Then, the four remaining scores are averaged, and the person with the highest average score wins the gold medal. Instructions:?? 1. Assume that each judge’s score is an integer. For each of 3 snowboarders (will a loop be helpful with this?), you will be prompting the user to enter the following data on one line using the keyboard: firstname lastname score1 score2 score3 score4 score5 score6 The user should be instructed to separate each data element by at least one space. 2. The first and last name of each snowboarder should be read in and stored in separate arrays named firstnames and lastnames. (If you want to practice more with strings, you may want to explore how to read in and save the whole name at one time and save it in an array called names.) 3. A loop should be used to read in and save scores for each snowboarder into an array of integers named scores. The snowboarder with the highest floating point average of four scores (see description above to understand which four scores) is the winner of the gold6. Include in the Example section of your lab report an example worked by hand, using the following sample data below (with a pretend mix of male/female USA athletes). Name Six judges’ scores Avg (excluding min and max)
Sean White 96 98 88 99 98 87
97.75
Chloe Kim 92 99 100 98 99 97
98.25
Ben Ferguson 90 95 91 85 94 88
90.75
7. Write the code to determine the average score for each competitor. For each snowboarder, display a message stating the person’s whole name and the average of that snowboarder’s four scores. This will help verify that your program works correctly for each person. 8. Finally, write the code to determine the gold medal-winning score. Display a message stating the winner’s whole name and average score.
1) Apply the problem-solving process from initial problem analysis through code testing 2) Use decomposition to identify main tasks, and determine the correct sequence for the tasks in order to solve the problem 3) Practice using keyboard input to fill arrays 4) Practice using loops to process data in arrays using common algorithms Description: The topic of this programming assignment is determining the gold-medal winner of a half-pipe snowboarding competition, based on scores that are examples of actual data compiled and analyzed during the recent winter Olympic Games in South Korea. The name of all snowboarders and scores earned for one run are saved in a data file. A snowboarder’s halfpipe run is scored as follows: • A team of six judges scores each halfpipe run. In the actual games, competitors had three runs to try to earn their very highest possible score. However, for this lab, the data for each snowboarder will reflect just their highest score, regardless on which run it occurred. • Each judge gives a subjective score from 1 to 100 based on overall impression, composed of height maintained throughout the run; variety and difficulty of maneuvers; and execution skill. (The six individual scores are not publicized, so we will have to make an assumption on data type.) • The highest and lowest scores of the six judges are dropped for the run. • Then, the four remaining scores are averaged, and the person with the highest average score wins the gold medal. Instructions:?? 1. Assume that each judge’s score is an integer. For each of 3 snowboarders (will a loop be helpful with this?), you will be prompting the user to enter the following data on one line using the keyboard: firstname lastname score1 score2 score3 score4 score5 score6 The user should be instructed to separate each data element by at least one space. 2. The first and last name of each snowboarder should be read in and stored in separate arrays named firstnames and lastnames. (If you want to practice more with strings, you may want to explore how to read in and save the whole name at one time and save it in an array called names.) 3. A loop should be used to read in and save scores for each snowboarder into an array of integers named scores. The snowboarder with the highest floating point average of four scores (see description above to understand which four scores) is the winner of the gold
6. Include in the Example section of your lab report an example worked by hand, using the following sample data below (with a pretend mix of male/female USA athletes). Name Six judges’ scores Avg (excluding min and max)
Sean White 96 98 88 99 98 87
97.75
Chloe Kim 92 99 100 98 99 97
98.25
Ben Ferguson 90 95 91 85 94 88
90.75
7. Write the code to determine the average score for each competitor. For each snowboarder, display a message stating the person’s whole name and the average of that snowboarder’s four scores. This will help verify that your program works correctly for each person. 8. Finally, write the code to determine the gold medal-winning score. Display a message stating the winner’s whole name and average score.
1) Apply the problem-solving process from initial problem analysis through code testing 2) Use decomposition to identify main tasks, and determine the correct sequence for the tasks in order to solve the problem 3) Practice using keyboard input to fill arrays 4) Practice using loops to process data in arrays using common algorithms Description: The topic of this programming assignment is determining the gold-medal winner of a half-pipe snowboarding competition, based on scores that are examples of actual data compiled and analyzed during the recent winter Olympic Games in South Korea. The name of all snowboarders and scores earned for one run are saved in a data file. A snowboarder’s halfpipe run is scored as follows: • A team of six judges scores each halfpipe run. In the actual games, competitors had three runs to try to earn their very highest possible score. However, for this lab, the data for each snowboarder will reflect just their highest score, regardless on which run it occurred. • Each judge gives a subjective score from 1 to 100 based on overall impression, composed of height maintained throughout the run; variety and difficulty of maneuvers; and execution skill. (The six individual scores are not publicized, so we will have to make an assumption on data type.) • The highest and lowest scores of the six judges are dropped for the run. • Then, the four remaining scores are averaged, and the person with the highest average score wins the gold medal. Instructions:?? 1. Assume that each judge’s score is an integer. For each of 3 snowboarders (will a loop be helpful with this?), you will be prompting the user to enter the following data on one line using the keyboard: firstname lastname score1 score2 score3 score4 score5 score6 The user should be instructed to separate each data element by at least one space. 2. The first and last name of each snowboarder should be read in and stored in separate arrays named firstnames and lastnames. (If you want to practice more with strings, you may want to explore how to read in and save the whole name at one time and save it in an array called names.) 3. A loop should be used to read in and save scores for each snowboarder into an array of integers named scores. The snowboarder with the highest floating point average of four scores (see description above to understand which four scores) is the winner of the gold
6. Include in the Example section of your lab report an example worked by hand, using the following sample data below (with a pretend mix of male/female USA athletes). Name Six judges’ scores Avg (excluding min and max)
Sean White 96 98 88 99 98 87
97.75
Chloe Kim 92 99 100 98 99 97
98.25
Ben Ferguson 90 95 91 85 94 88
90.75
7. Write the code to determine the average score for each competitor. For each snowboarder, display a message stating the person’s whole name and the average of that snowboarder’s four scores. This will help verify that your program works correctly for each person. 8. Finally, write the code to determine the gold medal-winning score. Display a message stating the winner’s whole name and average score.
Explanation / Answer
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
import java.util.stream.IntStream;
public class Solution {
public static void main(String args[] ) {
Scanner in = new Scanner(System.in);
String[] firstname=new String[3];
String[] lastname=new String[3];
int[][] scores=new int[3][6];
float[] avg=new float[3];
float max_avg=0;
int max_avg_index=0;
for(int i=0;i<3;i++) {
firstname[i]=in.next();
lastname[i]=in.next();
for(int j=0;j<6;j++) {
scores[i][j]=in.nextInt();
}
Arrays.sort(scores[i]);
int min=scores[i][0];
int max=scores[i][5];
int sum=IntStream.of(scores[i]).sum();
avg[i]=((float)sum-min-max)/(float)4;
if(max_avg<=avg[i]) {
max_avg=avg[i];
max_avg_index=i;
}
System.out.println(avg[i]);
}
System.out.println(firstname[max_avg_index]+" "+lastname[max_avg_index]+" "+max_avg);
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.