Docsity

Assignment 3: Class Roll - Java Programming | COP 2250, Assignments of Javascript programming

Toggle sidebar
bg1
Assignment 3: Class Roll
Due Date: March 28, 2008 at the beginning of the class
Late assignments will not be accepted.
Write a program to help maintain a class roll. Your program must contain three classes:
Student, Exams, and ClassRoll.
Class Exams: Students take three exams maintained by the class:
Private Instance
Variables:
int score1 Score of the first exam
int score2 Score of the second exam
int score3 Score of the third exam
Constructor No parameters Initializes all exam scores to zero
Public Methods: setScore1(), setScore2(),
setScore3(),
getScore1(),getScore2(),
getScore3(),
Setters and getters for each the scores
String toString() Returns a string containing the scores in each
of the three exams. The exam scores are to be
separated by a tab.
Class Students: The class Student maintains student information:
Private Instance
Variables:
String fName The first name of the student
String lName The last name of the student
Exams scores Scores for three exams
Constructor Students(String fn, String
ln)
Initializes fName and lName to fn and ln,
respectively. Initializes all exam scores to zero
Public Methods: setScore1(), setScore2(),
setScore3()
Setters for each the scores
String toString() Returns a string containing student’s first
name, last name and scores in each of the three
exams. The information must be separated by a
tab.
getAverage() Returns the student’s average in three exams
pf2

Partial preview of the text

Download Assignment 3: Class Roll - Java Programming | COP 2250 and more Assignments Javascript programming in PDF only on Docsity!

Assignment 3: Class Roll

Due Date: March 28, 2008 at the beginning of the class

Late assignments will not be accepted.

Write a program to help maintain a class roll. Your program must contain three classes: Student, Exams, and ClassRoll. Class Exams: Students take three exams maintained by the class: Private Instance Variables: int score1 Score of the first exam int score2 Score of the second exam int score3 Score of the third exam Constructor No parameters Initializes all exam scores to zero Public Methods: setScore1(), setScore2(), setScore3(), getScore1(),getScore2(), getScore3(), Setters and getters for each the scores String toString() Returns a string containing the scores in each of the three exams. The exam scores are to be separated by a tab. Class Students: The class Student maintains student information: Private Instance Variables: String fName The first name of the student String lName The last name of the student Exams scores Scores for three exams Constructor Students(String fn, String ln) Initializes fName and lName to fn and ln, respectively. Initializes all exam scores to zero Public Methods: setScore1(), setScore2(), setScore3() Setters for each the scores String toString() Returns a string containing student’s first name, last name and scores in each of the three exams. The information must be separated by a tab. getAverage() Returns the student’s average in three exams

Class ClassRoll: This class maintains student information (exactly 5 students) for one course: Private Static Variables Student st1, st2, st3, st4, st Students in the class String title The course title double courseAverage The average of all students Public Static Methods: Student setStudentInfo() Prompts the user for student information (first name, last name, score 1, score 2 and score3) and creates a student object, s, with the correct information and returns s. display Displays the class roll. The class roll must display each student record (first name, last name, score1, score 2, score3 and average) on a separate line. There must be an appropriate title and the class average must also be displayed. The class roll must be properly formatted (see the output example below) Main Calls getStudentInfo for each of the 5 students and calls display to display the class roll. Sample Output: COP 2250 First Name Last Name Exam1 Exam2 Exam3 Average John Smith 100 100 100 100. Josh Johnson 50 75 88 71. Alicia Antonio 30 54 100 61. Baba Bonton 95 78 87 86. Kevin Jones 45 67 99 70. Class Average = 77. Turn in enclosed envelope containing:

  1. Your .java source files on a diskette or CD.
  2. Printed listings of all your .java source code.