Hello all,
Im currently in an introductory Java class and I have an assignment thats causing me a little confusion. Im going to provide the program requirements in this thread to give you an idea of what my instructor is expecting. Im using Netbeans to write this code.
Here are the requirements:
Create a class called Student. This class should have the following twelve private data elements:
String studentName
String studentEmail
String studentLocation
int projectGrade1
int projectGrade2
int projectGrade3
int projectGrade4
int quizGrade1
int quizGrade2
int finalExam
int participationGrades
This class should have the following public methods at a minimum (but you may decide you need more):
A get method for each data element. For example:
public String getStudentName(); // note that the variable name starts with a lowercase, but in the method name it’s uppercased.
A set method for each data element. For example:
public void setStudentName(String name);
public void studentReport(); // prints to the screen a reportcard that shows the student’s name, contact information, grade for each assignment, and final grade. (this method should call finalGrade() directly to get the actual final grade value!)
Your project code will NOT have a main() method. You project must compile to create a file Student.class.
Formula to compute the final grade: project grades each * 0.1, plus quiz grades each * .05, plus final exam grade * 0.25, plus participation grade * 0.25.
The below driver program will be used to test your class. Note that this should be compiled as a separate file named gradeBookDriver.java. Do NOT modify gradeBookDriver; make your Student class meet the specified API so that the supplied gradeBookDriver works as-is.
public class gradeBookDriver {
public static void main (String[] args) {
Student cmis141Student1 = new Student();
Student cmis141Student2 = new Student();
cmis141Student1.setStudentName("Andy");
cmis141Student1.setStudentEmail("andy@hotmail.com" );
cmis141Student1.setStudentLocation("UK");
cmis141Student1.setProjectGrade1(100);
cmis141Student1.setProjectGrade2(90);
cmis141Student1.setProjectGrade3(85);
cmis141Student1.setProjectGrade4(95);
cmis141Student1.setQuizGrade1(100);
cmis141Student1.setQuizGrade2(80);
cmis141Student1.setFinalExam(80);
cmis141Student1.setParticipationGrades(0);
cmis141Student2.setStudentName("Heather");
cmis141Student2.setStudentEmail("heather@hotmail.c om");
cmis141Student2.setStudentLocation("Germany");
cmis141Student2.setProjectGrade1(100);
cmis141Student2.setProjectGrade2(95);
cmis141Student2.setProjectGrade3(95);
cmis141Student2.setProjectGrade4(65);
cmis141Student2.setQuizGrade1(80);
cmis141Student2.setQuizGrade2(90);
cmis141Student2.setFinalExam(85);
cmis141Student2.setParticipationGrades(90);
cmis141Student1.studentReport();
cmis141Student2.studentReport();
} // end of main() method
} // end of gradeBookDriver
You have three (3) deliverables for this project:
1. Student.java (correctly formatted) (80%)
2. Student.class (10%)
3. A screen capture or copy of the output of running gradeBookDriver with your Student class. (10%)
Your output will look something like this:
------------------------------------------
Student: Andy
Location: UK
Contact information: andy@hotmail.com
Grade Report
------------------------------------------
Quiz 1 100
Quiz 2 80
Project 1 100
Project 2 90
Project 3 85
Project 4 95
Participation 0
Final Exam 80
-------
Final Grade: 66.0
------------------------------------------
------------------------------------------
Student: Heather
Location: Germany
Contact information: heather@hotmail.com
Grade Report
------------------------------------------
Quiz 1 80
Quiz 2 90
Project 1 100
Project 2 95
Project 3 95
Project 4 65
Participation 90
Final Exam 85
-------
Final Grade: 87.75
------------------------------------------
End of the requirements
My confusion comes in where the instructor says that this will compile to the Student.class file and can be tested.
Here is what I have written for the Student.class.
public class Student {
private String studentName;
private String studentEmail;
private String studentLocation;
private int projectGrade1;
private int projectGrade2;
private int projectGrade3;
private int projectGrade4;
private int quizGrade1;
private int quizGrade2;
private int finalExam;
private int participationGrades;
public void setStudentName(String str) {
this.studentName = str;
}
public String getStudentName() {
return studentName;
}
public void setStudentEmail(String str) {
this.studentEmail = str;
}
public String getStudentEmail() {
return studentEmail;
}
public void setStudentLocation(String str) {
this.studentLocation = str;
}
public String getStudentLocation() {
return studentLocation;
}
public void setProjectGrade1(int proj1) {
this.projectGrade1 = proj1;
}
public int getProjectGrade1() {
return projectGrade1;
}
public void setProjectGrade2(int proj2) {
this.projectGrade2 = proj2;
}
public int getProjectGrade2() {
return projectGrade2;
}
public void setProjectGrade3(int proj3) {
this.projectGrade3 = proj3;
}
public int getProjectGrade3() {
return projectGrade3;
}
public void setProjectGrade4(int proj4) {
this.projectGrade4 = proj4;
}
public int getProjectGrade4() {
return projectGrade4;
}
public void setQuizGrade1(int qui1) {
this.quizGrade1 = qui1;
}
public int getQuizGrade1() {
return quizGrade1;
}
public void setQuizGrade2(int qui2) {
this.quizGrade2 = qui2;
}
public int getQuizGrade2() {
return quizGrade2;
}
public void setFinalExam(int finex) {
this.finalExam = finex;
}
public int getFinalExam() {
return finalExam;
}
public void setParticipationGrades(int num) {
this.participationGrades = num;
}
public int getParticipationGrades() {
return participationGrades;
}
public double finalGrade() {
double projectGrade = ((projectGrade1 * 0.1) + (projectGrade2 * 0.1) + (projectGrade3 * 0.1) + (projectGrade4 * 0.1));
double quizGrade = ((quizGrade1 * 0.5) + (quizGrade2 * 0.5));
double finalTest = (finalExam * 0.25);
double participationGrade = (participationGrades * 0.25);
double finalGpa = (projectGrade + quizGrade + finalTest + participationGrade);
return finalGpa;
}
public void studentReport() {
System.out.println("--------------------");
System.out.println("Student: " + studentName + "\n" + "Location: " + studentLocation + "\n" + "Contact information: " + studentEmail);
System.out.println("Grade Report" + "\n" + "--------------------");
System.out.println("Quiz1: " + quizGrade1 + "\n" + "Quiz2: " + quizGrade2);
System.out.println("Project1: " + projectGrade1 + "\n" + "Project2: " + projectGrade2 + "\n" + "Project3: " + projectGrade3 + "\n" + "Project4: " + projectGrade4);
System.out.println("Participation: " + participationGrades);
System.out.println("Final Exam: " + finalExam);
System.out.println("------");
System.out.println("Final Grade: " + finalGrade());
}
}