Question

Jason, Samantha, Ravi, Sheila, and Ankit are preparing for an upcoming marathon. Each day of the week, they run a certai...

Jason, Samantha, Ravi, Sheila, and Ankit are preparing for an upcoming
marathon. Each day of the week, they run a certain number of miles and
write them into a notebook. At the end of the week, they would like to
know the number of miles run each day, the total miles for the week, and
average miles run each day. Write a program to help them analyze their
data. Your program must contain parallel arrays: an array to store the
names of the runners and a two-dimensional array of five rows and seven
columns to store the number of miles run by each runner each day. Furthermore,
your program must contain at least the following functions: a
function to read and store the runners’ names and the numbers of miles
run each day; a function to find the total miles run by each runner and
the average number of miles run each day, and a function to output the
results. (You may assume that the input data is stored in a file and each
line of data is in the following form: runnerName milesDay1 milesDay2
milesDay3 milesDay4 milesDay5 milesDay6 milesDay7.)

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

Editable code

#include<stdio.h>

void total(char names[5][15],int runs[5][7])
{
   int sum=0,i,j;
   for(i=0;i<5;i++)
   {
       printf("%s\t\t",names[i]);
       for(j=0;j<7;j++)
       sum=sum+runs[i][j];
       printf("%d is total runs\n ",sum);
       sum=0;
   }
}

void print(char names[5][15],int runs[5][7])
{
   int i,j;
   for(i=0;i<5;i++)
   {
       printf("%s\t\t",names[i]);
       for(j=0;j<7;j++)
       printf("%d ",runs[i][j]);
       printf("\n");
   }
}

void average(char names[5][15],int runs[5][7])
{
   int i,j;
   for(j=0;j<7;j++)
   {
       int sum=0;
       for(i=0;i<5;i++)
       sum=sum+runs[i][j];
       printf("%d is the average of runs on %d day\n",sum/7,j+1);
   }
}

void input(char names[5][15],int runs[5][7])
{
   int i,j;
   for(i=0;i<5;i++)
   {
       printf("enter the name\n");
       scanf("%s",names[i]);
       for(j=0;j<7;j++)
       {
       printf("enter runs on %d date\n",j+1);
       scanf("%d",&runs[i][j]);
       }
   }
}
int main()
{
char names[5][15];
int runs[5][7];
input(names,runs);
print(names,runs);
total(names,runs);
average(names,runs);
   return 0;
}

IMAGES OF CODE

#include<stdio.h> by individual one //function to find the total runs void total (char names [5] [l5],int runs [5] [7]) 2 3 4

/function to print the arrays of names and runs of each one void print (char names [5] [15],int runs[5][7]) 15 16 17B int i,j27 /function to find the average runs on each day 28 29 B 30 void average (char names [5] [15],int runs [5] [7]) int i,j for39 /function to take input 40 void input (char names [5] [15] ,int runs [5] [71) 41 B { 42 43 44E 45 46 int i,j; for (i-0;i<5int main () 54 55 char names [5] [15]; int runs [5] [7]; input (names ,runs); print (names,runs); total (names,runs); averageJason 10 12 13 14 10 15 15 Samantha Ravi 12 13 13 14 14 14 15 14 15 15 15 15 16 16 Sheila 13 13 13 14 14 14 15 Ankit 14 14 15

Add a comment
Know the answer?
Add Answer to:
Jason, Samantha, Ravi, Sheila, and Ankit are preparing for an upcoming marathon. Each day of the week, they run a certai...
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
  • From: Java Programming: From Problem Analysis to Program Design, 5th ed. Ch. 9, page 636, Problem...

    From: Java Programming: From Problem Analysis to Program Design, 5th ed. Ch. 9, page 636, Problem Exercise 12: Jason, Samantha, Ravi, Sheila, and Ankit are preparing for an upcoming marathon. Each day of the week they run certain miles and write them into a notebook. At the end of the week, they would like to know the number of miles run each day, the total miles for the week, and average miles run each day. Write a program to help...

  • can someone please comment through this code to explain me specifically how the variables and arrays...

    can someone please comment through this code to explain me specifically how the variables and arrays are working? I am just learning arrays code is below assignment C++ Programming from Problem Analysis to Program Design by D. S. Malik, 8th ed. Programming Exercise 12 on page 607 Lab9_data.txt Jason, Samantha, Ravi, Sheila, and Ankit are preparing for an upcoming marathon. Each day of the week, they run a certain number of miles and write them into a notebook. At the...

  • Function Name: runBabyRun Inputs: (double) Target distance to run before half-marathon (double) A 4x7 array of...

    Function Name: runBabyRun Inputs: (double) Target distance to run before half-marathon (double) A 4x7 array of miles run each day in the month of February Outputs: (double) The most improvement made between consecutive days (logical) Whether you met your target distance for a single run (double) 1x4 vector of how many total miles you ran each week Function Description: With this New Year, you decide that you are actually going to run that half-marathon that has been on your calendar...

  • Write the definition of the class Tests such that an object of this class can store...

    Write the definition of the class Tests such that an object of this class can store a student's first name, last name, five test scores, average test score, and grade. (Use an array to store the test scores.) Add constructors and methods to manipulate data stored in an object. Among other things, your class must contain methods to calculate test averages, return test averages, calculate grades, return grades, and modify individual test scores. The method toString must return test data...

  • Write a complete C++ program that reads students names and their test scores from an input...

    Write a complete C++ program that reads students names and their test scores from an input text file. The program should output each student’s name followed by the test scores and the relevant grade in an output text file. It should also find and display on screen the highest/lowest test score and the name of the students having the highest/lowest test score, average and variance of all test scores. Student data obtained from the input text file should be stored...

  • this is a java course class. Please, I need full an accurate answer. Labeled steps of...

    this is a java course class. Please, I need full an accurate answer. Labeled steps of the solution that comply in addition to the question's parts {A and B}, also comply with: (Create another file to test the class and output to the screen, not an output file) please, DO NOT COPY others' solutions. I need a real worked answer that works when I try it on my computer. Thanks in advance. Write the definition of the class Tests such...

  • Write a C++ program that asks user number of students in a class and their names....

    Write a C++ program that asks user number of students in a class and their names. Number of students are limited to 100 maximum. Then, it will ask for 3 test scores of each student. The program will calculate the average of test scores for each student and display with their names. Then, it will sort the averages in descending order and display the sorted list with students’ names and ranking. Follow the Steps Below Save the project as A4_StudentRanking_yourname....

  • The XYZ Company needs you to write a program that will allow them to enter the...

    The XYZ Company needs you to write a program that will allow them to enter the weekly sales for a salesperson and then the program will calculate things such as most sales (and what day on which they happened), least sales (and day on which they happened), total sales, and daily average. The program will need to do the following: • Validate the user input to ensure that it is not less than 0.0 (0.0 will be acceptable if there...

  • IN JAVA USING ECLIPSE The objective of this assignment is to create your own hash table...

    IN JAVA USING ECLIPSE The objective of this assignment is to create your own hash table class to hold employees and their ID numbers. You'll create an employee class to hold each person's key (id number) and value (name). Flow of the main program: Create an instance of your hash table class in your main method. Read in the Employees.txt file and store the names and ID numbers into Employee objects and store those in your hash table using the...

  • Write a C++ program that demonstrates use of programmer-defined data structures (structs), an array of structs, passing...

    Write a C++ program that demonstrates use of programmer-defined data structures (structs), an array of structs, passing an array of structs to a function, and returning a struct as the value of a function. A function in the program should read several rows of data from a text file. (The data file should accompany this assignment.) Each row of the file contains a month name, a high temperature, and a low temperature. The main program should call another function which...

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
ADVERTISEMENT