Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Help with a program..

  1. #1
    Junior Member
    Join Date
    Sep 2011
    Thanked 0 Times in 0 Posts

    Default Help with a program..

    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.setStudentEmail("andy@hotmail.com" );

    cmis141Student2.setStudentEmail("heather@hotmail.c om");


    } // 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("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("Final Grade: " + finalGrade());

  2. #2

    Default Re: Help with a program..

    It looks fine to me. If your code compiles, then compile the driver program your instructor gave to you in the same directory as your Student.java or Student.class if they are in separate directories. The driver will run the code you created and produce output.
    Edit: Let me be clear... Put the Driver java file in the same place as your Student.java file. When you compile with Netbeans, it should create the Driver class file with the Student.class file. These class files need to be in the same directory because they are part of the same package (default package - because no package was specified).
    Last edited by kenster421; September 30th, 2011 at 11:10 AM. Reason: Clarification
    Kenneth Walter
    Software Developer

Similar Threads

  1. Help with class program!!! STUCK! Program not doing what I Want!!!
    By sketch_flygirl in forum What's Wrong With My Code?
    Replies: 7
    Last Post: April 4th, 2011, 07:29 AM