View the step-by-step solution to:

# I'm trying to understand this parallel array problem.

JAVA: I'm trying to understand this parallel array problem. I've already been able to create the two arrays, loop through the text files to load the arrays calculate the average method and return it to the main. I've got a semblance of a determine the letter grade and display the count. It's still off though. The resource files being used with this project are a list of names and a list of grades both with 20 entries each. I need to understand how to take an array of numbers and determine the letter grade. Then from that I need to figure out how many people have made that grade.

Requirements:

In your main method 1. Create two arrays, one for the names and one for the grades 2. Loop through the text files to load the arrays 3. Call the methods below to display the appropriate information 4. Promt the user to enter a specific name, if the name does not exist, indicate so, otherwise return individual letter grade. Write individual methods for the following:  Display how many people earned an A  Display how many people earned a B Who has the highest grade  Who has the lowest grade  What was the average grade  A method for the individual grade

Sort option is out for this, allowed to use Search methods. Below is the code provided.

```import java.io.File;
import java.io.IOException;
import java.nio.file.Paths;
import java.util.Scanner;

public static void main(String [] args) throws IOException {

File namesFile = Paths.get(".", "resources", "Names.txt").normalize().toFile();

// File file = new File(fileName);             // create a File object

if ( namesFile.exists() )
{                                             /

Scanner namesInputFile = new Scanner( namesFile );

// For each line in the file, read in the line and display it with the line number
int lineNum = 0;

// Use the results of calling the hasNext method to
// determine if you are at the end of the file before
// reading the next line of the file.
String[] names = new String[20];
int [] grades = new int[20];

while ( namesInputFile.hasNext() )
{
names[lineNum] = namesInputFile.nextLine(); //read the next line

// Output the line read to the screen for the user
System.out.println(lineNum + ": " + names[lineNum] );
++lineNum;//increment the line number
}

// When we're done reading the file,
// close the Scanner object attached to the file
namesInputFile.close();

System.out.print("The number of A's is: " + findNumberOfAs(grades));
}
}

public static int findNumberOfAs (int [] g) {

int total = 0;
for (int i = 0; i<g.length; i++) {
total++;
}
}
}

public static char findLetterGrade(int score) {
if (score>=90) {
return 'A';
}
else if (score>= 80) {
return 'B';
}
else if (score>=70) {
return 'C';
}
else if (score >=60) {
return 'D';
}
else {
return 'F';
}
}

}
```

### Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

### -

Educational Resources
• ### -

Study Documents

Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

Browse Documents