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

Read 11 bowlers (your name and scores will be the first bowler), with 3 scores e

ID: 3560023 • Letter: R

Question

Read 11 bowlers (your name and scores will be the first bowler), with 3 scores each from the attached data file. Calculate the averages across for each bowler, plus calculate the averages down for each game. Also find the highest average and lowest average and print them along with the bowlers names.

You need to put the bowlers names in one array of strings and the games in a muli-dimension array of integers.

The output needs to show each score, for each round by every bowler. ex

Name 1st game 2nd game 3rd game Average Becky Smith 100 200 300 200 Luke Green 200 250 290 248~ Averages: 150 225 295 Highest Avg/lowest Avg

Explanation / Answer

Record file f1.txt is at the bottom

Just copy and past the following program

#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(){
   string nameOfBowler[11]={};//evelen bowlers as you mentioned
   int scoreRecord[11][3];// 11 bowlers and 3 games
   string temp;
   cout <<"Reading data from file ";
   ifstream fin;
   ofstream fout;
   fin.open("f1.txt");//path of your file
   //assuming each bowler have first name as well as last name.if you don't want let me i will make as you desire
   for(int i=0;i<11;i++){
       fin>>nameOfBowler[i];
       fin.ignore();
       fin>>temp;
       fin.ignore();
       nameOfBowler[i].append(" ");
       nameOfBowler[i].append(temp);
       for(int j=0;j<3;j++){
           fin>>scoreRecord[i][j]; // get scores from the file
       }
   }
   cout <<" NameofBowler 1stgame 2ndGame 3rdGame Average ";
   for(int i=0;i<11;i++)
   {
       int avg=0;
       cout <<nameOfBowler[i] << " ";
       for(int j=0;j<3;j++){
           cout <<scoreRecord[i][j] <<" ";
           avg+=scoreRecord[i][j];
       }
       avg=avg/3;
       cout << " "<<avg <<" ";
   }
   int fstGmeAvg=0,sndGmeAvg=0,thdGmeAvg=0;
   for(int i=0;i<11;i++)
   {
       fstGmeAvg+=scoreRecord[i][0]; //1 first game average
   }
   fstGmeAvg=fstGmeAvg/11;
   for(int i=0;i<11;i++)
   {
       sndGmeAvg+=scoreRecord[i][1]; //2 second game average
   }
   sndGmeAvg=sndGmeAvg/11;
   for(int i=0;i<11;i++)
   {
       thdGmeAvg+=scoreRecord[i][2]; //3 third game average
   }
   thdGmeAvg=thdGmeAvg/11;

   cout <<"Averages: " <<fstGmeAvg <<" "<<sndGmeAvg<<" "<<thdGmeAvg<<" ";

   //calculating higest and lowest averages

   if(fstGmeAvg>sndGmeAvg && sndGmeAvg > thdGmeAvg){

       cout <<" Highest average : "<<fstGmeAvg<<" " <<"Lowest Average : "<<thdGmeAvg;
   }
   else if(sndGmeAvg > fstGmeAvg && fstGmeAvg > thdGmeAvg){

       cout <<" Highest average : "<<sndGmeAvg <<" " <<"Lowest Average : "<<thdGmeAvg;
   }
   else if(sndGmeAvg >thdGmeAvg && thdGmeAvg >fstGmeAvg){

       cout <<" Highest average : "<<sndGmeAvg <<" " <<"Lowest Average : "<<fstGmeAvg;
   }

   else if(thdGmeAvg > fstGmeAvg && fstGmeAvg > sndGmeAvg){
       cout <<" Highest average : "<<thdGmeAvg <<" " <<"Lowest Average : "<<sndGmeAvg;
   }
   else if(thdGmeAvg > sndGmeAvg && sndGmeAvg > fstGmeAvg){
       cout <<" Highest average : "<<thdGmeAvg <<" " <<"Lowest Average : "<<fstGmeAvg;
   }
   char wait;
   cout <<"Press any key to exit ........";
   cin.get(wait);
   return 0;
}

Make file name f1.txt in your project directory where .cpp file exits and past the record given below

Becky Smith 100 250 300
Luke Green 200 250 290
waqas nadeem 300 400 100
Mola Jhut 100 400 200
Nori Naut 100 200 100
Mola Jhuft 100 400 200
Moley Jhfut 100 430 200
Mikla Jhdfut 100 420 200
aa Jfahut 100 410 200
Mafola gdJshut 100 400 200
Mike tyson 100 200 110

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