0

:sad: I am overwhelmed and need help. I am trying to write object oriented programning using Java code.

1st Class contain variables for firstname, lastname and SSn as string. 4 different class scores as integers with different weights for the depending upon the course. I've also included set and get methods.

2nd class extends the first with a default and non-default construtor and methods for selecting couse, checking scores and so on.

3rd class has instance of the 2nd and have method calls to set data in the objects to display the name, SSN, and course names(at least 3) the final scores, letter grade for ea course and total credits and GPA.

This is my code so far: Need help to piece this all together:

Student Grade Systems */

    public class Student
    {
        private String firstName;
        private String lastName;
        private String socialSecurityNumber;
        private double midTerm;
        private double finalExam;
        private double researchProject;
        private double presentationScore;
        private double credithours;
        private double average;
        int totalCourses;
        int sum;
        char finalGrade;

        // constructor to initialize variables
        public Student( String fName, String lName, String ssn )
        {
            firstName = fName;
            lastName = lName;
            socialSecurityNumber = ssn;
        } // end Student constructor



        //
        public Student( int exam, int mTerm, int project, int presentation)
        {
            finalExam = exam;
            midTerm = mTerm;
            researchProject = project;
            presentationScore = presentation;
        }// end constructor


        // set first name
        public void setFirstName( String fName )
        {
            firstName = fName;
        } // end method setFirstName

        // return first name
        public String getFirstName()
        {
            return firstName;
        } // end method getFirstName


        // set last name
        public void setLastName( String lName )
        {
            lastName = lName;
        } // end method setLastName


        // return last name
        public String getLastName()
        {
            return lastName;
        } // end method getLastName


        // set social security number
        public void setSocialSecurityNumber( String ssn )
        {
            socialSecurityNumber = ssn;
        } // end method setSocialSecurityNumber


        // return social security number
        public String getSocialSecurityNumber()
        {
            return socialSecurityNumber;
        } // end method getSocialSecurityNumber


        public void setInsy3300(int course1)
        {
            double sum = 0;
            this.midTerm = midTerm *.50;
            this.finalExam = finalExam * .50;
            sum = midTerm + finalExam;
        }

        public int getInsy3300()
        {
            return sum;
        }

        public void setInsy3305( int course2)
        {
            double sum = 0;
            this.researchProject = researchProject * .75;
            this.presentationScore = presentationScore * .25;
            sum = researchProject + presentationScore;
        }

        public int getInsy3305()
        {
            return sum;
        }

        public void setInsy4304( int course3)
        {
            double sum = 0;
            this.midTerm = midTerm * .25;
            this.finalExam = finalExam * .25;
            this.researchProject = researchProject *.25;
            this.presentationScore = presentationScore * .25;
            sum = midTerm + finalExam + researchProject + presentationScore;
        }

        public int getInsy4304()
        {
            return sum;
        }

        public void setInsy4305( int course4)
        {
            double sum = 0;
            this.midTerm =  midTerm * .30;
            this.finalExam =  finalExam * .40;
            this.researchProject =  researchProject * .30;
            sum = midTerm + finalExam + researchProject;
        }

        public int getInsy4305()
        {
            return sum;
        }

        public void setInsy4310( int course5)
        {
            double sum = 0;
            this.midTerm =  midTerm * .25;
            this.finalExam = finalExam * .50;
            this.presentationScore = presentationScore * .25;
            sum = midTerm + finalExam + presentationScore;
        }

        public int getInsy4310()
        {
            return sum;
        }

        public void setInsy4320( int course6)
        {
            double sum = 0;
            this.researchProject = researchProject *.40;
            this.presentationScore = presentationScore *.20;
            this.finalExam =  finalExam *.40;
            sum = researchProject + presentationScore + finalExam;
        }

        public int getInsy4320()
        {
            return sum;
        }
        //
        public String toString()
        {
            return String.format(
                "%s %s\t%s", firstName, lastName, socialSecurityNumber);
        } // end method toSring

        }

***********
import java.util.Scanner;

    public class InsyStudent extends Student
    {



            public InsyStudent( String fName, String lName, String ssn )
        {

            //explicit call to superclass Student
            super( fName, lName, ssn );


        }

                public void selectCourse()
                {
                    Scanner input = new Scanner( System.in);

                    int total = 0; // sum of courses entered
                    int courseCounter = 0; // number of courses entered


                    System.out.printf( "\nSelect number for a course and press enter: ",
                        "(Must choose at least 3 courses)");
                        input.nextInt();
                    }
            }
                    switch (

                    case 1:
                    System.out.print( "Enter grade for MidTerm: ");
                        midTerm = input.nextInt();
                    courseCounter = courseCounter + 1;
                    break;

                    System.out.print( "Enter grade for Final: ");
                        finalExam = input.nextInt();
                    break;

                    case 2:
                    System.out.print( "Enter grade for Proj: ");
                        researchProject = input.nextInt();

                    System.out.print( "\nEnter grade for Pres: ");
                        presentationScore = input.nextInt();
                    break;

                    case 3:
                    System.out.print( "Enter grade for MidTerm: ");
                    System.out.print("\nEnter grade for Final: ");
                    System.out.print( "\nEnter grade for Proj: ");
                    System.out.print( "\nEnter grade for Pres: ");
************
import java.util.Scanner;

    public class MyApp
    {
        public static void main( String args[] )
        {
            //
            InsyStudent app = new InsyStudent()

        public void inputData( String fName, String lName, String ssn )
        {

            Scanner input = new Scanner( System.in);

                    System.out.println( "Enter Student's First Name: ");
                        fName = input.nextInt();

                    System.out.println( "\nEnter Student's last Name: ");
                        lName = input.nextInt();

                    System.out.println( "\nEnter Student's SSN: ");
                        ssn = input.nextInt();

                    System.out.print( "\nFor INSY 3300 Choose Option 1 ");
                    System.out.print( "\nFor INSY 3305 Choose Option 2 ");
                    System.out.print( "\nFor INSY 4304 Choose Option 3 ");
                    System.out.print( "\nFor INSY 4305 Choose Option 4 ");
                    System.out.print( "\nFor INSY 4310 Choose Option 5 ");
                    System.out.print( "\nFor INSY 4320 Choose Option 6 ");
                }

Edited by Dani: Formatting fixed

2
Contributors
1
Reply
3
Views
13 Years
Discussion Span
Last Post by jerbo
0

Not sure what you mean by "Put it alltogether"
But in simple terms, each class will go into its own file (with the name of the file the same as the Class name.) So your Student class will be Student.java, Your InsyStudent class will be InsyStudent.java.

The only other thing I noticed is you explicitly call the Student (super) constructor with parameters in the InsyStudent constructor. In Java If you declare a Constructor with parameters, you also need to create a default constructor without parameters, otherwise you will get an error when compiling. This is true for the Student class. I think (but I am not totally sure it is also true for the InsyStudent class as well, since you created a InsyStudent constructor with parameters too.)

Hope this helps.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.