Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

this is hw1 code: //for using files import java.io.File; //for reading data from file import java.util.Scanner; //for store data in list import java.util.ArrayList; //for find

image text in transcribed

image text in transcribed

this is hw1 code:

//for using files import java.io.File; //for reading data from file import java.util.Scanner; //for store data in list import java.util.ArrayList; //for find squre and squareroot values import java.lang.Math;

public class Scores { //main method public static void main(String args[]) { try{ File file = new File("ScoresInput.txt"); //getting data from file using Scanner Scanner sc = new Scanner(file); //store ids in idarraylist ArrayList idarray = new ArrayList(); //store ids in namearraylist ArrayList namesarray = new ArrayList(); //store ids in scores arraylist ArrayList scoresarray = new ArrayList(); //check data in file using hasNextLine method //if data is there then method return true else return false while(sc.hasNextLine()) { //get data using nextLine method and convert string to integer idarray.add( Integer.parseInt(sc.nextLine())); //get data using nextLine method namesarray.add(sc.nextLine()); //get data using nextLine method and convert string to integer scoresarray.add( Integer.parseInt(sc.nextLine())); } double scoresum = 0; //store score sum double standarddeviationsum = 0; //to store standard deviation sum double avgscore = 0; //store avg score double standarddeviation = 0; //to store standard deviation for( int i=0; i=90)) { grade = 'A'; } else if((((int)scoresarray.get(j))>=80) && (((int)scoresarray.get(j))=70) && (((int)scoresarray.get(j))=60) && (((int)scoresarray.get(j)) avgscore) { System.out.println(namesarray.get(j) + " " + (int)scoresarray.get(j) + " " + ">Average"+ " " + grade ); } else { System.out.println(namesarray.get(j) + " " + (int)scoresarray.get(j) + " " + "

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

50 Tips And Tricks For MongoDB Developers Get The Most Out Of Your Database

Authors: Kristina Chodorow

1st Edition

1449304613, 978-1449304614

More Books

Students also viewed these Databases questions

Question

Given the following source code: for(int j = 1; j

Answered: 1 week ago