Latest Tutorials| Questions and Answers|Ask Questions?|Site Map




Have Programming Question? Ask it here!
 
 
 


Priti Saba
Java
0 Answer(s)      a year and 10 months ago
Posted in : Java Beginners


Create a package named cs520.hw4.part2. Using this package, create the following classes. 1. Create a class named Student as follows. The class keeps track of the student√Ę‚?¨‚?Ęs homework grades. a. The instance (or member) private variables √Ę‚?¨‚?? name (String), homework1, homework2, homework3, homework4, homework5 and homework6 (all of type integer). b. A single constructor with name as its argument. c. The public set methods for the six homework instance variables. The get methods are optional. d. A public computeAverage method which takes no arguments and returns a double showing the average homework grade for this student. e. Override the toString method to return the string representation of this object in the format √Ę‚?¨Ň?The √Ę‚?¨‚?Ęs average grade is √Ę‚?¨¬?.

  1. Create a Test class to test the following functionality in its main method. a. Use the BufferedReader class to read the data.txt file. The contents of the file are shown below. Create the data.txt file in HW4_lastName. b. 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. Invoke the processInputData method for each line read. c. Write a private method processInputData which processes its string input argument as follows.
  2. Tokenize the string argument using the StringTokenizer class using the comma as the delimiter.
  3. Extract the name token. Create a Student object and assign to the variable currentStudent.
  4. Read each homework grade token one token at a time. Use the corresponding set method on the student object to set the instance value.
  5. Display the string representation of the currentStudent object to the console.

    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

  Sample Output:

Alice's average grade is 69.00 .....


Advertisement
View Answers

Related Tutorials/Questions & Answers:
Advertisements
 

 

 

DMCA.com