Question: this is hw1 code: import java.io.File; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.Scanner; public class HW1 { public static void main(String[] args) { // update the

![java.util.Scanner; public class HW1 { public static void main(String[] args) { //](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f025ce73b74_34966f025cdebdd9.jpg)
this is hw1 code:
import java.io.File; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.Scanner; public class HW1 { public static void main(String[] args) { // update the file path location in the below line File file = new File("F:HW1_STudents.txt"); ArrayList studentNums = new ArrayList(); ArrayList studentNames = new ArrayList(); ArrayList studentGrades = new ArrayList(); try { Scanner scanner = new Scanner(file); while (scanner.hasNextLine()) { String studentNumStr = scanner.nextLine(); int studentNum = Integer.parseInt(studentNumStr); studentNums.add(studentNum); studentNames.add(scanner.nextLine()); studentGrades.add(Double.parseDouble(scanner.nextLine())); } scanner.close(); } catch (FileNotFoundException e) { System.out.println("File not found"); System.exit(1); } // this method displays the final output displayResult(studentNames, studentGrades); } // returns the average public static double getAverage(ArrayList scores) { double totalScore = 0.0; for (double score : scores) { totalScore += score; } return totalScore / scores.size(); } // calculates the standard deviation for all the scores public static double getStandardDeviation(ArrayList scores) { double average = getAverage(scores); double standardSum = 0.0; for (double score : scores) { standardSum += Math.pow(score - average, 2); } return Math.sqrt(standardSum / (scores.size() - 1)); } // retuns the grade as per the given condition, takes a score and returns grade public static String getLetterGrade(double 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"; } } // outputs the result in the console public static void displayResult(ArrayList names, ArrayList scores) { System.out.println("Group Average: " + String.format("%.2f", getAverage(scores)) + " Standard deviation: " + String.format("%.6f", getStandardDeviation(scores))); System.out.println(String.format(" %-20s%-10s%-20s%-20s", "Student", "Score", "Relative to Average", "Letter Grade")); for (int index = 0; index = getAverage(scores)) { System.out.println(String.format("%-20s%-10.2f%-20s%-20s", studentName, studentScore, ">Average", getLetterGrade(studentScore))); } else { System.out.println(String.format("%-20s%-10.2f%-20s%-20s", studentName, studentScore, " Need help for this work!thank you!
The program you wrote for HW1 treated Student ID (int), Full name (last, first) (String) and Test score (double) as somewhat unrelated variables. For this project, create a Student class with these variables as its data members (aka properties, attributes, instances variables) along with setter and getter methods for them plus a toString method for producing a nicely formatted view of an object's state. This program will perform all the actions of the previous one with two key differences: it will put the values it reads from the file into the data members of a Student object then add each object to either an ArrayList or a Linkedlist of Students (your choice). It will produce its output by looping through the ArrayList or Linkedlist using an extended "for" statement. Process this data as before: " Calculate the average score for the group " Determine whether a particular score is greater than, equal to or less than the average " Derive a letter grade for each numeric score " Calculate the standard deviation of the group of scores This time, we'll maintain only a list of Student object in memory instead of separate ArrayLists of individual varaibles. The rules for deriving a letter grade are: . Numeric grade >= 90, A' . Numeric grade >= 80 and 90, B * Numeric grade >- 70 and = 60 and Average Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
