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

Jason Ravi Shiela, and Ankit run each day of the week certain number of miles by

ID: 3647748 • Letter: J

Question

Jason Ravi Shiela, and Ankit run each day of the week certain number of miles by writing them in a book. At the end of the week, they would like to know the number of miles they run each day, the total miles for the week, Write a program that uses parallel arrays concept to store the name of each runner in character array and a two dimensional array of 5 rows and 7 columns to store the number of miles run by each runner each day. The program must contain the following functions: A function to input and store the runners name and the miles run each day in declared arrays write data to a file "Runners.Dat" by using following data. Don't write the column headings to a file. A function to read the data from a file "Runners.dat" and then find the total miles run by each runner and the average number of miles run each day. The function should also find and display the name of the runner who ran the lowest miles and the runner who ran the highest average miles. The function should display the data in the following format:

Explanation / Answer

please rate - thanks

I'm messaging you the sample run it's too big for this post

#include <iostream>
#include <fstream>
using namespace std;
void inputData();
void readData();
int main()
{inputData();
readData();
system("pause");
return 0;
}
void inputData()
{ofstream out;
char name[5][30];
int miles[5][7];
int num,i,j;
cout<<"How many runners are there: ";
cin>>num;

for(i=0;i<num;i++)
    {cout<<"Runner "<<i+1<<endl;
    cout<<"Enter name: ";
    cin.ignore(256,' ');
    cin.get (name[i],30,' ');
   
     for(j=0;j<7;j++)
         {cout<<"Miles run, day "<<j+1<<": ";
         cin>>miles[i][j];
            }
         
    }       
out.open("Runners.dat");
for(i=0;i<num;i++)
    {out<<name[i]<<" ";
    for(j=0;j<7;j++)
         out<<miles[i][j]<<" ";
    out<<endl;
    }
out.close();
}
void readData()
{ifstream in;
in.open("Runners.dat");       
if(in.fail())           
   { cout<<"Runners.dat file did not open please check it ";
   system("pause");
   system("exit");
   }
char first[5][30],last[5][30];
int miles[5][7],total[5],hi,lo;
double average[5];
int num,i=0,j;
in>>first[i];
while(in)
    {in>>last[i];
    total[i]=0;
    for(j=0;j<7;j++)
       {in>>miles[i][j];
       total[i]+=miles[i][j];
       }
     average[i]=total[i]/7.;
    i++;
    in>>first[i];
    }
num=i;
cout<<"Runner         ";
for(i=0;i<7;i++)
    cout<<"Miles ";
cout<<"Total Average ";
cout<<" Name          ";
for(i=0;i<7;i++)
    cout<<"Day "<<i+1<<" ";
cout<<"Miles Miles ";
for(i=0;i<num;i++)
   {cout<<first[i]<<" "<<last[i]<<" ";
   for(j=0;j<7;j++)
       cout<<miles[i][j]<<" ";
   cout<<total[i]<<" "<<average[i]<<endl;
    }
hi=0;
lo=0;
for(i=1;i<num;i++)
    {if(average[i]>average[hi])
         hi=i;
      if(average[i]<average[lo])
         lo=i;  
     }
cout<<"Runner "<<first[lo]<<" "<<last[lo]
     <<" ran the lowest average miles "<<average[lo]<<" in a week. ";
cout<<"Runner "<<first[hi]<<" "<<last[hi]
     <<" ran the highest average miles "<<average[hi]<<" in a week. ";
}

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