Discount Get CS 520 ALL WEEKS Solution ONLY $154.91
CS520, CIS 520, CIS 520 Week 1 assignment - iLab 1 - Lab 1 - Java... [$8.99]
CS520, CIS 520, CIS 520 Week 2 assignment Part 1 - iLab 2 - Lab 2... [$11.99]
CS520, CIS 520, CIS 520 Week 2 assignment Part 2 - iLab 2 - Lab 2... [$15.99]
CS520, CIS 520, CIS 520 Week 2 assignment Part 3 - iLab 2 - Lab 2... [$19.99]
CS520, CIS 520, CIS 520 Week 3 assignment Part 1 - iLab 3 - Lab 3... [$15.99]
CS520, CIS 520, CIS 520 Week 3 assignment Part 2 - iLab 3 - Lab 3... [$19.99]
CS520, CIS 520, CIS 520 Week 4 assignment Part 1 and Part 2 - iLa... [$21.99]
CS520, CIS 520, CIS 520 Week 5 assignment - iLab 5 - Lab 5 - Java... [$19.99]
CS520, CIS 520, CIS 520 Week 6 assignment - iLab 6 - Lab 6 - Java... [$19.99]
Get Selected Weeks Solution with ONLY NOT Add Selected Tutorials To Cart
CS520, CS 520, CS 520 Week 5 assignment - iLab 5 - Lab 5 - Java Programming
    CS520, CS 520, CS 520 Week 5 assignment - iLab 5 - Lab 5 - Java Programming CS520, CS 520, CS 520 Week 5 assignment - iLab 5 - Lab 5 - Java Programming

CS520, CS 520, CS 520 Week 5 assignment - iLab 5 - Lab 5 - Java Programming

$19.99

CS520 Week 5 Assignment

Create a package named cs520.hw5. Using this package, create the following classes.

 Create a class named Student as follows. The class keeps track of the student’s homework grades. This is a modification of HW4 using arrays.
The instance (or member) private variables – name (String), homeworks (an integer array).
A static public integer variable, NUM_HOMEWORKS, initialized to 6.
A single constructor with name as its argument. Also, allocate the space for the homeworks array to hold NUM_HOMEWORKS values
The public get  and set methods for the name instance variable.
A void setHomeworkGrade method which takes two arguments – a zero based index of the homework and the corresponding homework grade. In the body of the method, store the homework grade into the corresponding array location.
A public computeAverage method which takes no arguments and returns a double showing the average homework grade for this student. You should use a for loop to add the homework grades and then compute the average. This code should be independent of the length of the homework array.
Override the toString method to return the string representation of this object in the format “The <studentName>’s average grade is <the computed average>”.
 

Create a Test class to test the following functionality in its main method.
a.Declare and initialize an empty ArrayList of Student objects named studentList.

b.Declare and initialize an empty HashMap named studentMap. The keys will be the names of the students and the entries in the map will be the corresponding student objects.

c. Use the BufferedReader class to read the data.txt file. The contents of the file are shown below. Create the data.txt file in HW5_lastName.

d.Read the contents of the text file one line at a time using a loop. The program should work for any number of input lines. In this loop,

Invoke the processInputData method for each line read. This method returns the corresponding Student object.
Add this Student object to the studentList.
Insert this Student object into the studentMap using the student’s name as the key.
e.After the loop is processed, do the following.

Create an iterator for the studentList. Iterate over each element in the list using this iterator. Display each element to the console.
Access the keys of the studentMap and assign them to an appropriate variable. Create an iterator over the keys. Iterate over each key in this set and display the associated object in the map to the console.
 

Write a private method processInputData with return type Student which processes its string input argument and returns the corresponding Student object as follows.

Tokenize the string argument using the StringTokenizer class using the comma as the delimiter.
Extract the name token. Create a Student object and assign to the variable currentStudent.
Use a counter variable, initialized to 0, to keep track of the homework index.
Using a while loop, read the next homework grade token. Use the setHomeworkGrade method on the student object to set the homework grade for this homework. Make sure to increment the counter in the loop.
Display the string representation of the currentStudent object to the console.
The method should return the currentStudent object.
 Sample Input data.txt file:

 

Alice,44,79,85,72,77,57

Bob,79,94,70,71,71,51

Charlie,95,99,41,55,65,50

Dave,87,89,88,55,74,63

Ed,82,51,44,67,73,49 

My tutorial contains Java Programs - Eclipse Project and Document.

If you have more questions, please contact me via email support@extutorials.com

I will help you any time

Thank you !

Attached Files

Move over [ preview ] file name to preview content in it!

Write a review

Your Name:


Your Review: Note: HTML is not translated!

Rating: Bad           Good

Enter the code in the box below:



Tags: CS520, CS 520
PURCHASE SAVE
2 Tutorials 10%
3 Tutorials 13%
4 Tutorials 16%
5 Tutorials 19%
6 Tutorials 22%
7 Tutorials 25%
8 Tutorials 28%
9 Tutorials 31%
10 Tutorials 34%
add url more

9MZQASHWN73B