must use three methods and two arrays to match the provided output with the prov
ID: 3704598 • Letter: M
Question
must use three methods and two arrays to match the provided output with the provided input
This program will be used to help tabulate the results of a fishing contest at the Rocking JR ranch in southwest Shawnee County There will be 7 competitors, identified only by their number (1 thru 7)-They must bring in their fish to be weighed periodically. The competitor with the highest score will be the winner. The data will be in the following order ./The data will be in groups of 2 numbers, the first number will be a number between 1 and 7, followed by the weight of the fish caught ./| After all entries are tabulated, print out (single spaced and in competitor order) the competitor number and his/her total for each competitor, then after a blank line print the competitor number and total weight of fish caught by the winner and the competitor number and total weight of fish caught by the least successful Output should appear as follows: Sample input: Results of the Rocking JR Fishing contest 3 3.7 2 12 1 7.3 3 3.6 6 11.1 5 3.7 2 8.65 7 10.5 5 7.2 4 13.75 1: 7.45 2 4.6 6 17.4 78.25 4 12.7 2 9.35 5 8.1 Competitor Total Number Weight 14.75 34.60 7.30 26.45 19.00 28.50 18.75 5 7 winner is Not as Successful Contest over 34.60 3 7.30 I expect you to write three (3) methods, one to find the largest weight, one to find the smallest weight, and one to print the contestant results. You must pass in the two arrays to each method, return the location of the largest(smallest) weight for the first two methods, and return nothing for the thirdExplanation / Answer
/******************************************************************************
Online C Compiler.
Code, Compile, Run and Debug C program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <stdio.h>
void findSmallest(int[],float[]);
void findLargest(int[],float[]);
int main()
{
int id[100],noRecords,counter;
float weights[100];
printf("Enter number of records");
scanf("%d",&noRecords);
for(counter=1;counter<=noRecords;counter++){
scanf("%d",&id[counter]);
scanf("%f",&weights[counter]);
}
// for(counter=1;counter<=noRecords;counter++){
// printf("%d",id[counter]);
// printf("%f",weights[counter]);
// }
findSmallest(id, weights);
findLargest(id,weights);
return 0;
}
void findLargest(int id[], float weights[]){
float tempId[8], max = weights[1];
int counter, counter1, index = 0;
for(counter=1;counter<8;counter++){
for(counter1=1; counter1<8;counter1++){
if(id[counter1] == counter){
tempId[counter] += weights[counter1];
}
if(tempId[counter]>max){
max = tempId[counter];
index = counter;
}
}
}
printf(" Max is %f %d",max,index);
for(counter1=1;counter1<8;counter1++)
printf(" %f",tempId[counter1]);
}
void findSmallest(int id[], float weights[]){
float tempId[8], min = weights[1];
int counter, counter1, index = 0;
for(counter=1;counter<8;counter++){
for(counter1=1; counter1<8;counter1++){
if(id[counter1] == counter){
tempId[counter] += weights[counter1];
}
}
// if(tempId[counter]<min && tempId[counter] > 0){
// min = tempId[counter];
// index = counter;
// }
}
for(counter1=1;counter1<8;counter1++)
printf(" %f",tempId[counter1]);
min = tempId[1];
for(counter1=1;counter1<8;counter1++){
if(tempId[counter1]>1){
if(tempId[counter1]<min || min==0){
printf("vlz %f",tempId[counter1]);
min = tempId[counter1];
index = counter1;
}
}
}
printf(" Min is %2f %d",min,index);
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.