The code below is a C++ code for the istructions that follow this note. I have a issue with lines 53 and 54: static[runCount][0] = total; static[runCount][1] = avg; The = signs have the red error lines under them and I don't know why. If possible could you please find and correct what I did wrong and make sure it runs please. Thank you. 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 the 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.)   #include #include #include #include using namespace std; const int COUNT = 5; const int DAYS = 7; void inputData(string names[], int sizeOfName, double numOfMiles[][DAYS], int rowSize) { ifstream infile; infile.open("Data.txt"); int checkNames = 0, checkMiles = 0; while (checkNames < sizeOfName) { infile >> names[checkNames]; while (checkMiles < DAYS) { infile >> numOfMiles[checkNames][checkMiles]; checkMiles++; } checkMiles = 0; checkNames++; } } void computeMiles(double status[][2], double numOfMiles [][DAYS], int rowSize) { double total = 0, avg = 0; int runCount = 0, num = 0; cout << fixed << showpoint << setprecision(2) << endl; while (runCount < rowSize) { while (num < DAYS) { total = total + numOfMiles[runCount][num]; num++; } avg = (total/DAYS); static[runCount][0] = total;   //error = static[runCount][1] = avg;    // error = total = 0; avg = 0; num = 0; runCount++; } } void displayResult(double status[][2], string names[], int sizeOfName) { cout << setw(10) << "Runner_Name" << setw(12) << "Total miles" << setw(10) << "Average" << endl; int runCount = 0; while (runCount < sizeOfName) { cout << setw(10) << names[runCount] << setw(12) << status[runCount][0] << setw(10) << status[runCount] [1] << endl; runCount++; } } int main() { string names[COUNT]; double milesStatus[COUNT][DAYS]; double output[COUNT][2]; inputData(names, 5, milesStatus, 5); computeMiles(output, milesStatus, 5); displayResult(output, names, 5); system("PAUSE"); return 0; }

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter2: Using Data
Section: Chapter Questions
Problem 4E: In this chapter, you learned that although a double and a decimal both hold floating-point numbers,...
icon
Related questions
Question

The code below is a C++ code for the istructions that follow this note. I have a issue with lines 53 and 54:

static[runCount][0] = total;
static[runCount][1] = avg;

The = signs have the red error lines under them and I don't know why. If possible could you please find and correct what I did wrong and make sure it runs please. Thank you.

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 the 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.)

 

#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
using namespace std;

const int COUNT = 5;
const int DAYS = 7;

void inputData(string names[], int sizeOfName,
double numOfMiles[][DAYS], int rowSize)

{

ifstream infile;
infile.open("Data.txt");
int checkNames = 0, checkMiles = 0;

while (checkNames < sizeOfName)
{
infile >> names[checkNames];
while (checkMiles < DAYS)
{

infile >> numOfMiles[checkNames][checkMiles];
checkMiles++;
}
checkMiles = 0;
checkNames++;
}

}

void computeMiles(double status[][2], double numOfMiles
[][DAYS], int rowSize)
{

double total = 0, avg = 0;
int runCount = 0, num = 0;

cout << fixed << showpoint << setprecision(2) << endl;
while (runCount < rowSize)
{
while (num < DAYS)
{
total = total + numOfMiles[runCount][num];
num++;
}

avg = (total/DAYS);
static[runCount][0] = total;   //error =
static[runCount][1] = avg;    // error =
total = 0;
avg = 0;
num = 0;
runCount++;
}
}

void displayResult(double status[][2], string names[],
int sizeOfName)

{
cout << setw(10) << "Runner_Name" << setw(12)
<< "Total miles" << setw(10) << "Average" << endl;
int runCount = 0;
while (runCount < sizeOfName)
{
cout << setw(10) << names[runCount] << setw(12)
<< status[runCount][0] << setw(10) << status[runCount]
[1] << endl;
runCount++;
}
}
int main()
{
string names[COUNT];
double milesStatus[COUNT][DAYS];
double output[COUNT][2];

inputData(names, 5, milesStatus, 5);
computeMiles(output, milesStatus, 5);
displayResult(output, names, 5);

system("PAUSE");
return 0;

}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Datatypes
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning