Question

i need help with this program, I am stuck at it /* My typedef structures from...

i need help with this program, I am stuck at it

/* My typedef structures from a different file */

Typedef struct {

                             Char name[21];

                             Double attempts[N_ATTEMPTS];

                             Double personal_best;

                             Double deviation;

                             }jumper_t;

Typedef struct {

                             Double average_of_best;

                             Double winning_jump;

                             }stats_t;

Pseudocode

/*-------------------------------------------------------------*/

main   

out_file = open_out_file ();                     

get_data(IN_FILENAME, jump_list);                

get_stats(jump_list, &jump_stats);             

print_all(out_file, jump_list, &jump_stats);  

/*-------------------------------------------------------------*/

FILE * open_out_file(void)         /* It already exists */

/*-------------------------------------------------------------*/

void get_data (char *filename,                                /* input */              

jumper_t jump_list[NCOMPETITORS] ); /* output */

     /*It already exists */

/*-------------------------------------------------------------*/

/*     The print_all SUB-FUNCTION is provided for you          */

void print_all(FILE * out_file, jumper_t jump_list[NCOMPETITORS] , stats_t *jump_stats )

     /* It already exists */

/*-------------------------------------------------------------*/

CSC 60. Spring 2017. Lab 8 arrays & structures.  

Page 3 of 5.

/*--------------------------------------------------------------------------------*/

/*     THIS IS A SUB-FUNCTION THAT YOU HAVE TO WRITE         */

void get_stats( jumper_t jump_list[NCOMPETITORS],     /* in & out */     

    stats_t *jump_stats )                                  /* in & out */         

                      {   

Zero out the average_of_best. (HINT: use the -> notation)    

Zero out the winning_jump.      

Loop from r=zero to r< NCOMPETITORS increment by one   

{        

set the jumper's personal_best to the jumper's first jump        

loop from c=one to c< N_ATTEMPTS increment by one         

{             

figure the jumper’s personal_best jump(use an IF)      

   }         

add the jumper's personal _best jump into the running total average_of_best         

loop from c=zero to c< N_ATTEMPTS increment by one         

{             

figure the winning_jump (use an IF)        

}    

}         /* end of the loop, r< NCOMPETITORS */    

compute the average of the best jumps

    loop from r=zero to < NCOMPETITORS increment by one   

{          

figure the jumper's deviation from the winning_jump             

(deviation is: winning_jump - jumper's personal_best jump)   

}  

return

} /*-------------------------------------------------------------*/

0 0
Add a comment Improve this question Transcribed image text
Answer #1

/* My typedef structures from a different file */
Typedef struct {
Char name[21];
Double attempts[N_ATTEMPTS];
Double personal_best;
Double deviation;
}jumper_t;
Typedef struct {
Double average_of_best;
Double winning_jump;
}stats_t;


Pseudocode

/*-------------------------------------------------------------*/
main   
out_file = open_out_file ();   
get_data(IN_FILENAME, jump_list);
get_stats(jump_list, &jump_stats);   
print_all(out_file, jump_list, &jump_stats);

/*-------------------------------------------------------------*/
FILE * open_out_file(void) /* It already exists */

/*-------------------------------------------------------------*/
void get_data (char *filename, /* input */
jumper_t jump_list[NCOMPETITORS] ); /* output */

/*It already exists */

/*-------------------------------------------------------------*/
/* The print_all SUB-FUNCTION is provided for you */
void print_all(FILE * out_file, jumper_t jump_list[NCOMPETITORS] , stats_t *jump_stats )

/* It already exists */

/*-------------------------------------------------------------*/



CSC 60. Spring 2017. Lab 8 arrays & structures.
Page 3 of 5.


/*--------------------------------------------------------------------------------*/
/* THIS IS A SUB-FUNCTION THAT YOU HAVE TO WRITE */
void get_stats( jumper_t jump_list[NCOMPETITORS], /* in & out */   
stats_t *jump_stats ) /* in & out */   
{   
//Zero out the average_of_best. (HINT: use the -> notation)
jump_stats->average_of_best = 0;
//Zero out the winning_jump.
jump_stats->winning_jump = 0;

//Loop from r=zero to r< NCOMPETITORS increment by one   
for(int r = 0; r < NCOMPETITORS; r++)
{
    // set the jumper's personal_best to the jumper's first jump
    jump_list[r].personal_best = jump_list[r].attempts[0];
    // loop from c=one to c< N_ATTEMPTS increment by one   
    for(int c = 1; c < N_ATTEMPTS; c++)
    {   
       //figure the jumper’s personal_best jump(use an IF)
       if(jump_list[r].attempts[c] > jump_list[r].personal_best)
           jump_list[r].personal_best = jump_list[r].attempts[c];
    }
    //add the jumper's personal _best jump into the running total average_of_best   
    jump_stats->average_of_best += jump_list[r].personal_best;
    // loop from c=zero to c< N_ATTEMPTS increment by one   
    for(int c = 0; c < N_ATTEMPTS; c++)
    {   
       //figure the winning_jump (use an IF)
       if( jump_list[r].attempts[c] > jump_stats->winning_jump)
           jump_stats->winning_jump = jump_list[r].attempts[c];
    }
} /* end of the loop, r< NCOMPETITORS */
//compute the average of the best jumps
jump_stats->average_of_best /= NCOMPETITORS;
//loop from r=zero to < NCOMPETITORS increment by one   
for(int r = 0; r < NCOMPETITORS; r++)
{
    //figure the jumper's deviation from the winning_jump   
    //(deviation is: winning_jump - jumper's personal_best jump)   
    jump_list[r].deviation = jump_stats->winning_jump - jump_list[r].personal_best;
}
return
} /*-------------------------------------------------------------*/

Add a comment
Know the answer?
Add Answer to:
i need help with this program, I am stuck at it /* My typedef structures from...
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
  • Currently I am learning about set theory. I am trying to implement a set using a hashtable with singly linked lists. I a...

    Currently I am learning about set theory. I am trying to implement a set using a hashtable with singly linked lists. I am very confused as to where I should start, as many of the online resources reference basically hash table implementations. How would I go about a template to implement the very basic structures needed for the set in C? Just confused as to where to start. Currently this is my current structure: typedef struct s_entry t char *key...

  • I JUST NEED HELP WITH DISPLAY PART! please help! thanks in advance // This function saves...

    I JUST NEED HELP WITH DISPLAY PART! please help! thanks in advance // This function saves the array of structures to file. It is already implemented for you. // You should understand how this code works so that you know how to use it for future assignments. void save(char* fileName) { FILE* file; int i; file = fopen(fileName, "wb"); fwrite(&count, sizeof(count), 1, file); for (i = 0; i < count; i++) { fwrite(list[i].name, sizeof(list[i].name), 1, file); fwrite(list[i].class_standing, sizeof(list[i].class_standing), 1, file);...

  • Hello! I'm posting this program that is partially completed if someone can help me out, I...

    Hello! I'm posting this program that is partially completed if someone can help me out, I will give you a good rating! Thanks, // You are given a partially completed program that creates a list of employees, like employees' record. // Each record has this information: employee's name, supervisors's name, department of the employee, room number. // The struct 'employeeRecord' holds information of one employee. Department is enum type. // An array of structs called 'list' is made to hold...

  • I wrote a program which computes the area and perimeter of a square, circle, or rectangle. As you will see in my main function, there is a for loop in which the user is supposed to be able repeat the...

    I wrote a program which computes the area and perimeter of a square, circle, or rectangle. As you will see in my main function, there is a for loop in which the user is supposed to be able repeat the program until they enter "q" to quit. However, my program runs through one time, the prompt appears again, but then it terminates before the user is allowed to respond to the prompt again. I'm not able to debug why this...

  • Writing a program in C please help!! My file worked fine before but when I put...

    Writing a program in C please help!! My file worked fine before but when I put the functions in their own files and made a header file the diplayadj() funtion no longer works properly. It will only print the vertices instead of both the vertices and the adjacent like below. example input form commnd line file: A B B C E X C D A C The directed edges in this example are: A can go to both B and...

  • Please help!! I am supposed to write a program in C++ about student & grades. Needs...

    Please help!! I am supposed to write a program in C++ about student & grades. Needs to have two functions that sorts students letter grade, and another one to sort Students name in your student’s record project. Remember, to add necessary parameters and declaration in main to call each function properly. Order of functions call are as follow Read Data Find Total Find average Find letter grade Call display function Call sort letter grade function Call display function Call sort...

  • I need help on this Systems review please! it's due by midnight monday. Question 1 Not...

    I need help on this Systems review please! it's due by midnight monday. Question 1 Not yet answered Points out of 1.00 Flag question Question text Using these declarations: int * numberPointers[3]; int * pointer; int number; Which of the following statements would generate a warning or error? Select one: a. number = pointer; b. *pointer = number; c. pointer = numberPointers; d. numberPointers[2] = &number; e. a., b., and d. f. a. and c. Question 2 Not yet answered...

  • (Write a program, and show the output too) C programming I have a hard time to...

    (Write a program, and show the output too) C programming I have a hard time to get these five questions done. I am thankful if someone can help me with that. I started with something but i couldn't get it done. That's what I've done. #include <stdio.h> typedef struct _profile {    char name[32];    int age; } Profile; Profile prof[3] = {"myName", 19}, {"bob", 12} arr[1] = prof; for (int i = 0; i < 3; i++) {   ...

  • Write a program, called wordcount.c, that reads one word at a time from the standard input....

    Write a program, called wordcount.c, that reads one word at a time from the standard input. It keeps track of the words read and the number of occurrences of each word. When it encounters the end of input, it prints the most frequently occurring word and its count. The following screenshot shows the program in action: adminuser@adminuser-VirtualBox~/Desktop/HW8 $ wordCount This is a sample. Is is most frequent, although punctuation and capitals are treated as part of the word. this is...

  • PROGRAMING IN C. PLEASE HELP FIX MY CODE TO FIT THE FOLLOWING CRITERIA: 1.)Read your stocks...

    PROGRAMING IN C. PLEASE HELP FIX MY CODE TO FIT THE FOLLOWING CRITERIA: 1.)Read your stocks from your mystocks.txt file. You can use this information for the simulator. 2.)The stock price simulator will return the current price of the stock. The current prices is the prices of the requested ticker + a random number. 3.)We will assume that the stock price remains constant after the price check till your trade gets executed. Therefore, a buy or a sell order placed...

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