IN JAVA Read the runners data file into arrays. ONE string array and ONE 2-dimension array. Each runner has 8 pieces of data, which includes name, and how much they ran for each of 7 days. Print out the raw data in columns. Below the raw data, print out the total miles ran for all of the runners.
THIS IS TXT FILE :
Keith
10
8
4
5
12
3
2
Anna
9
8
7
6
5
12
13
Derick
1
2
0
22
11
0
7
Susan
4
5
6
7
8
9
2
Note: Create a input.txt file in D drive with following details
Keith
10
8
4
5
12
3
2
Anna
9
8
7
6
5
12
13
Derick
1
2
0
22
11
0
7
Susan
4
5
6
7
8
9
2
Here is the screenshot

Code:
import java.io.*; //to read data from file
public class Runner
{
// counter is used for type of data. eg runner name, day1,
day2...day7
// i is used for runner. eg runner1, runner2....runner7
int counter=0, i=0;
String nameList[] = new String[4];//we have 4 runner data so kept
array size =4, change if required.
int day1[] = new int[4];
int day2[] = new int[4];
int day3[] = new int[4];
int day4[] = new int[4];
int day5[] = new int[4];
int day6[] = new int[4];
int day7[] = new int[4];
int total[] = new int[4];
String line;
void readFromFile()
{
try
{
// BufferedReader object to read data from file
BufferedReader read = new BufferedReader(new
FileReader("d:\\input.txt"));
while ((line = read.readLine()) != null) //read data line by
line
{
if(counter%8==0) //counter will keep track about type of data
nameList[i]=line;
else if(counter%8==1)
{
day1[i] = Integer.parseInt(line);//convert string to number
total[i] = total[i] + day1[i];//to count total for each
runner
}
else if(counter%8==2)
{
day2[i] = Integer.parseInt(line);
total[i] = total[i] + day2[i];
}
else if(counter%8==3)
{
day3[i] = Integer.parseInt(line);
total[i] = total[i] + day3[i];
}
else if(counter%8==4)
{
day4[i] = Integer.parseInt(line);
total[i] = total[i] + day4[i];
}
else if(counter%8==5)
{
day5[i] = Integer.parseInt(line);
total[i] = total[i] + day5[i];
}
else if(counter%8==6)
{
day6[i] = Integer.parseInt(line);
total[i] = total[i] + day6[i];
}
else if(counter%8==7)
{
day7[i] = Integer.parseInt(line);
total[i] = total[i] + day7[i];
//increase i as we have collected data for ith runner, now need to
collect data for (i+1)th runner
i++;
}
counter++;
}
read.close(); //close input file
}
catch(FileNotFoundException e) //exception for file not found
{
System.out.println("File not found.");
}
catch(Exception ex) //other exceptions like permission denied
{
System.out.println(ex.toString());
}
}
void showData()
{
System.out.print("\n");
for(int x=0; x<i; x++) //i is having count of total no or
runner
{
System.out.print(nameList[x] + " "); //print name
}
System.out.print("\n");
for(int x=0; x<i; x++)
{
if(day1[x]>=10) //if number is more than 2 digit than just print
number
System.out.print(day1[x] + " ");
else //if number is 1 digit than print number with a space
System.out.print(" " + day1[x] + " ");
}
System.out.print("\n");
for(int x=0; x<i; x++)
{
if(day2[x]>=10)
System.out.print(day2[x] + " ");
else
System.out.print(" " + day2[x] + " ");
}
System.out.print("\n");
for(int x=0; x<i; x++)
{
if(day3[x]>=10)
System.out.print(day3[x] + " ");
else
System.out.print(" " + day3[x] + " ");
}
System.out.print("\n");
for(int x=0; x<i; x++)
{
if(day4[x]>=10)
System.out.print(day4[x] + " ");
else
System.out.print(" " + day4[x] + " ");
}
System.out.print("\n");
for(int x=0; x<i; x++)
{
if(day5[x]>=10)
System.out.print(day5[x] + " ");
else
System.out.print(" " + day5[x] + " ");
}
System.out.print("\n");
for(int x=0; x<i; x++)
{
if(day6[x]>=10)
System.out.print(day6[x] + " ");
else
System.out.print(" " + day6[x] + " ");
}
System.out.print("\n");
for(int x=0; x<i; x++)
{
if(day7[x]>=10)
System.out.print(day7[x] + " ");
else
System.out.print(" " + day7[x] + " ");
}
System.out.print("\n---------------------------------------------");
System.out.print("\n");
for(int x=0; x<i; x++)//printing total
System.out.print(total[x] + " ");
System.out.print("\n---------------------------------------------");
System.out.print("\n\n");
}
public static void main(String arga[]) //main method to control
the program
{
Runner run = new Runner(); //crating object of class. it will call
constructor
run.readFromFile(); //call function to read data from file
run.showData(); //call function to print data
}
}
Output

Code Screenshot




IN JAVA Read the runners data file into arrays. ONE string array and ONE 2-dimension array....
JAVA ----Read the data from the file into the ArrayList(s) and print out the datavectors?? TXT Keith 10 8 4 5 12 3 2 Anna 9 8 7 6 5 12 13 Derick 1 2 0 22 11 0 7 Susan 4 5 6 7 8 9 2
Assume that an array A is given to you in a txt file. You should read it. If you think this is a time-dependent data, print the number of local minimums in the array to a txt file. Local minimum means the element which is less than the previous element and the following element. Please do not use any additional library. For example, if A=[3, 2, 9, 8, 7, 8, 6], the code should print 2 and 7. (Local minimums...
Therefore, for this program you will read the data in the file named weatherdata_2.txt into arrays for the wind speed and for the temperature. You will then use the stored data to calculate and output the average wind speed and the average temperature. Create a constant with a value of 30 and use that to declare and loop through your arrays and as a divisor to produce your averages. Here is the data file (below). 1. 14 25 2. 12...
IN PYTHON PLEASE...... Process bowlers and their 3 bowling scores. Use my data file below: bowlers2.txt ( Showed below) And you can also use a while loop to read your file if you prefer. How to average down an array, which you don’t have to do. In this case that would be the game 1 average for all bowlers for example. Find the low average and high average. Start with read the data into arrays/lists and printed out the arrays/lists...
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 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...
Create 4 arrays: a 1-D array to store the students’ id, 1-D array to store the students’ names, a parallel 2-D array to store the test scores, and a parallel 1-D array to store letter grades. Read data into the 3 arrays from the file data121.txt. If the file is not found, the program needs to terminate with this error, “Data file not found.” Calculate and store a letter grade into a 1-D array based on the total score, sum...
Create 4 arrays: a 1-D array to store the students’ id, 1-D array to store the students’ names, a parallel 2-D array to store the test scores, and a parallel 1-D array to store letter grades. Read data into the 3 arrays from the file data121.txt. If the file is not found, the program needs to terminate with this error, “Data file not found.” Calculate and store a letter grade into a 1-D array based on the total score,...
Read your notes concerning 2D arrays with particular attention to the syntax of passing arrays as parameters to functions. Write the pseudocode (algorithm) for the following program definition: A text file contains a square matrix of integer numbers. The file contains an integer number indicating the identical number of rows and columns followed by the data itself (that number cannot be larger than 100). For example, a file containing a 3x3 matrix would contain 3 followed by 9 other integer...
Python DESCRIPTION Write a program that will read an array of integers from a file and do the following: ● Task 1: Revert the array in N/2 complexity time (i.e., number of steps) . ● Task 2: Find the maximum and minimum element of the array. INPUT OUTPUT Read the array of integers from a file named “ inputHW1.txt ”. To do this, you can use code snippet from the “ file.py ” file. This file is provided in Canvas....