Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PLEASE HELP SETTING UP CODE WITH C! Description: The topic of this programming a

ID: 3706384 • Letter: P

Question

PLEASE HELP SETTING UP CODE WITH C!

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:               

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.

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

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

Complete the Problem Description, Input, Output, and Assumptions sections of a Lab Report. Decide on the tasks necessary for applying the rules to determine the gold medal winner.    In the Algorithm section of your lab report, draw a decomposition diagram showing an overview of the main tasks required.

Below the decomposition diagram in your lab report, list the sequence in which tasks should be executed. This is not a detailed algorithm, simply a high-level sequence.

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

100

97.75

Chloe Kim

92

99

100

98

99

97

98.25

Ben Ferguson

90

95

91

85

94

88

90.75

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.

Finally, write the code to determine the gold medal-winning score. Display a message stating the winner’s whole name and average score.  

Use the sample data to test your program and verify that actual results match expected results. In the Test Plan section of your lab report, document the first test case using the sample data, and also a screenshot of the execution results obtained using the sample data.

Next, construct a test case using test data of your own, and execute your program to verify that actual results match expected results. You may use your own choice of names (perhaps you and your friends?) and scores.   Document your test data in the in the Test Plan section of your lab report, and include a screenshot of the execution results using your test data.

Name

Six judges’ scores

Avg (excluding min and max)

Sean White

96

98

88

99

98

100

97.75

Chloe Kim

92

99

100

98

99

97

98.25

Ben Ferguson

90

95

91

85

94

88

90.75

Explanation / Answer

Below is your code: -

#include<stdio.h>

void bubbleSort(int arr[], int n);

int main()

{

int i,j,highestAvgIndex;

char firstname[3][20],lastname[3][20];

int scores[3][6];

float average = 0,highestAvgValue = 0;

for(i = 0 ;i < 3;i++)

{

/*Read the firstname and lastname of the three snow boarders */

printf("Enter the snow boarders data in the format : firstname lastname score1 score2 score3 score4 score5 score6 ");

scanf("%s %s",firstname[i],lastname[i]);

/*Read the six judges scores of the snow boarders boarders */

for(j = 0;j < 6 ;j++)

{

scanf("%d",&scores[i][j]);

}

}

/*Using bubble sort sort the scores of each snow boarders */

for(j = 0;j < 3 ;j++)

{

bubbleSort(scores[j], 6);

}

printf("FirstName LastName Average ");

printf("------------------------------ ");

for(i = 0 ;i < 3;i++)

{

printf("%-10s %-10s",firstname[i],lastname[i]);

/*Don't consider the firstelement and lastelement in the array because those onl the minimum and maximum values */

for(j = 1;j < 5 ;j++)

{

/*Calculate sum of the four snow boarders */

average += scores[i][j];

}

/*Calculate average */

average = average / 4;

/*Check new average is greater than the old one replace it and store it's index value */

if(average > highestAvgValue)

{

highestAvgValue = average;

highestAvgIndex = i;

}

printf(" %-7.2f ",average);

average = 0;

}

printf(" Winner is : %s %s",firstname[highestAvgIndex],lastname[highestAvgIndex]);

return 0;

}

/*Bubble sort technique for sorting array */

void bubbleSort(int arr[], int n)

{

int i, j, temp;

for (i = 0; i < n - 1; i++)

{

for (j = 0; j < n - i - 1; j++)

{

if (arr[j] > arr[j + 1])

{

temp = arr[j];

arr[j] = arr[j + 1];

arr[j + 1] = temp;

}

}

}

}

Output

Enter the snow boarders data in the format : firstname lastname score1 score2 score3 score4 score5 score6
Sean White 96 98 88 99 98 100
Enter the snow boarders data in the format : firstname lastname score1 score2 score3 score4 score5 score6
Chloe Kim 92 99 100 98 99 97
Enter the snow boarders data in the format : firstname lastname score1 score2 score3 score4 score5 score6
Ben Feguson 90 95 91 85 94 88
FirstName LastName Average
------------------------------
Sean White 97.75
Chloe Kim 98.25
Ben Feguson 90.75

Winner is : Chloe Kim

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote