Question
Program 3 which is to modify: package assignment1; import java.util.ArrayList; import java.util.Scanner; import java.text.DecimalFormat; /** * A class created to store the information about the
Program 3 which is to modify:
package assignment1; import java.util.ArrayList; import java.util.Scanner; import java.text.DecimalFormat; /** * A class created to store the information about the student: its first and last name and his test scores. * * @author Ahsan Shakeel */ public class Student { String firstName; //first name of the student String lastName; // last name of the student ArrayList
/** * This method calculates the average of the test scores of the students * * @return the average of the test scores */ public float getAverage() { float sum = 0; for(int i = 0; i
/** * This method calculates number of tests that a Student object has attempted * * @return the number of tests that a Student object has attempted */ public int getTestCount() { return testscores.size(); } public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println("Enter a student's data on a single line and press return:"); String data = input.nextLine(); String[] pieces = data.split(" "); Student obj = new Student(pieces[0], pieces[1]); for (int i = 2; i
This is an individual homework grade. The assignment is to modify program 3 to read in a list of students. PROGRAM REQUIREMENTS Prompt the user for the name of an input text data file. Open the file and read one student's data per line. Store all of the students in an ArrayList of student objects. ADDITIONAL INFORMATION - An example execution is shown below. Your code should work for any number of test grades entered on the line. And any number of students in the data file. - An example file for the sample shown is given at the end of this assignment document. - I will enter the full path name for the input file. - You may assume all of the data in the input file is valid. There are no data errors. Example execution on command line window, user input is show in green. Enter a the name of the input data file: C:|temp|in1.txt The student list from the data file contains 3 student entries The students are: Allen, Beth has 3 grades and an average of 100.0 Smith, John has 2 grades and an average of 87.0 Jones, Bob has 5 grades and an average of 69.6 One Example Input File: Beth Allen 100100100 John Smith 9876 Bob Jones 65658974
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started