this assignment here was my take home assignment. I am kinda doing it over just to see and know where i went wrong with. it is either my codes wrong somewhere but am not getting the required output.
I had to do two methods along with two arrays. dont know if my arrays were correctly done bcuz the output am getting is not what it was supposed to be:

here is an example hw the program should have run:
enter the student name: marcus smith
enter student id: 00012541
enter the academic year: 2015
enter the semester no: 2
enter the number of courses did in the above semester: 3 

student: marcus smith
student id: 00012541

academic year:2015
semester no: 2

courses pursed
itec 125
grade: a

gpa: 3.5


here is my codes and the output.ublic static int calGpa(int grdevalpt, int qpts){


       double grdeval;
        String usergrde;

        if("usergrde".equals("A"))
            grdeval = (4 * 3); 

        else if("usergrde".equals("B+"))
            grdeval = (3.5 * 3);

        else if("usergrde".equals("B"))
            grdeval = (3.0 * 3);

        else if("usergrde".equals("C+"))
            grdeval = (2.5 * 3);

        else if("usergrde".equals("C"))
            grdeval = (2 * 3);

        else if("usergrde".equals("D+"))
            grdeval = (1.5 * 5);

        else if("usergrde".equals("D"))
            grdeval = (1 * 3);

        else if("usergrde".equals("F"))
            grdeval = (0 * 3);

        else
            System.out.println("you are academic probation");


        return qpts;
    }


    public static void main(String[] args) 
    {
        Scanner putin = new Scanner(System.in);

        int grderec = 0, gpa = 0;
        int  credhrs =0, tqpts =0, grde;
        double cqpts;
        double calQualityPoints;
        int grdeval = 0, qpts = 0;



        System.out.println("Hi please enter your id number");
        int stidnum = putin.nextInt();

        System.out.println("Hi what is your name");
        String username = putin.next();

        System.out.println("Hi please enter the academic year");
        int acyr = putin.nextInt();

        System.out.println("Hi which semester did you register for");
        int semno = putin.nextInt();

        System.out.println("Hi how many course did you take");
        int numcourses = putin.nextInt();


        System.out.println("***********************************************");


        System.out.println("Hi what is your course code");
        String coursecde = putin.next();

        System.out.println("Hi how much is your course credit");
        int coursecred = putin.nextInt();

        System.out.println("Hi what is the grade code you recieved in the course taken");
        int grdecde = putin.nextInt();


        System.out.println("********************************************");

        cqpts = calQualityPoint(tqpts, credhrs);
        gpa =  calGpa(grdeval,qpts);

        int[] grades = new int[3];
        grades[0]= 'A';
        grades[1]= 'B';
        grades[2]= 'B';

        for(int i = 1; i<3; i++)
        {
            System.out.println("enter the students grades");
            String grade = putin.nextLine();

            System.out.println("the student grade is "  + grades[0]);
            System.out.println("the student grade is "  + grades[1]);
            System.out.println("the student grade is "  + grades[2]);
        }

        String[]courses = new String[3];
        courses[0]= "ITEC 133";
        courses[1]= "ITEC 224";
        courses[2]= "ITEC 121";


        for(int i = 1; i<3; i++)
        {
            System.out.println("enter the student courses");
            String usercourses = putin.nextLine();

            System.out.println("the student courses are "  + courses[0]);
            System.out.println("the student courses are "  + courses[1]);
            System.out.println("the student courses are "  + courses[2]);
        }

        System.out.println("the student id number is " + stidnum);
        System.out.println("the name of the student is " + username);
        System.out.println("the semester number is " + semno);
        System.out.println("the academic year is " + acyr);
        System.out.println("the number of course done " + numcourses);
        System.out.println("the grades recieved for each course are " + grderec);
        System.out.println("the gpa recieve for the given semester is" + gpa);



        and here is my output

run:
Hi please enter your id number
0002485
Hi what is your name
liselle
Hi please enter the academic year
2015
Hi which semester did you register for
2
Hi how many course did you take
3
***********************************************
Hi what is your course code
itec133
Hi how much is your course credit
3
Hi what is the grade code you recieved in the course taken
3
********************************************
you are academic probation
enter the students grades
the student grade is 65
the student grade is 66
the student grade is 66
enter the students grades
a
the student grade is 65
the student grade is 66
the student grade is 66
enter the student courses
itec133
the student courses are ITEC 133
the student courses are ITEC 224
the student courses are ITEC 121
enter the student courses
itec224
the student courses are ITEC 133
the student courses are ITEC 224
the student courses are ITEC 121
the student id number is 2485
the name of the student is liselle
the semester number is 2
the academic year is 2015
the number of course done 3
the grades recieved for each course are 0
the gpa recieve for the given semester is0
BUILD SUCCESSFUL (total time: 1 minute 19 seconds)

what is drastically wrong here

calGpa is a disaster area:
It takes two parameters, but uses neither of them
It has variable names in quotes in the if tests
Itr calculates grDval, but never uses it
It returns a value that is never set in the method

(I didn't get any further than that)

hi j

when you said it takes two parameters and never uses them, what do you mean and in the part with the if statement, when i put it in quotes, i was getting an error, telling me to initialized it, that is why it was in the quotes. it want me to initialized but you dont initialized string don you

You prompt the user for the number of courses taken (numcourses), but don't use that information. Instead you hardcoded a value of "3". Look at every place you've placed a "3" and ask yourself if perhaps that value should be replaced by "numcourses". Also, what is the purpose of a loop? Lines 93-99 should probably also be in a loop. This type of information would be perfect to be in it's own class. Have you learned about creating your own class yet? If not, then use multiple arrays as you have done.

hi j
I removed the quotes from the condition in the if statement in the method part and nw i am get this

Hi please enter your id number
0001252
Hi what is your name
shenelle
Hi please enter the academic year
2015
Hi which semester did you register for
2
Hi how many course did you take
3
***********************************************
Hi what is your course code
itec133
Hi how much is your course credit
3
Hi what is the grade code you recieved in the course taken
3
********************************************
Exception in thread "main" java.lang.NullPointerException
    at gpa.Gpa.calGpa(Gpa.java:29)
    at gpa.Gpa.main(Gpa.java:105)
Java Result: 1
BUILD SUCCESSFUL (total time: 38 seconds)

what going on dey

Start off by writing some pseudo code. See attached file.

Then, convert pseudo code to Java code. The following examples use the pseudo code from the attached file.

Example 1:
Create array to hold course names (Data type: String[]; Variable name: courseNameArr)

Code:

String[] courseNameArr = null;

Example 2:
Create variable to hold total grade points (Data type: double; Variable name: totalGradePoints)

Code:

double totalGradePoints = 0.0;

Example 3:
Initialize course name array (courseNameArr = new String[numcourses])

Code:

courseNameArr = new String[numcourses];

Example 4:
Store course name in course name array (courseNameArr[i])

Code:

courseNameArr[i] = coursecde;

I've left the formulas blank to give you an opportunity to come up with your own formulas.

Also, your program should do some sort of input validation. For example, if your grade point scale is from 0.0 - 4.0, if a user enters "5.0", the program should let the user know that he/she entered an invalid value and should prompt the user to enter a valid value.

thank u cgeir very much

"when you said it takes two parameters and never uses them, what do you mean"

static int calGpa(int grdevalpt, int qpts){

you pass two values, for grdevalpt and qpts, into this method, but you never use either of them in your calculations - so why pass them?

You then carefully calculate grdval, but you never use the value you have calculated.
finally you return qpts - which is just the value that that was passed to you as a parameter.

"in the part with the if statement, when i put it in quotes, i was getting an error, telling me to initialized it, that is why it was in the quotes. it want me to initialized but you dont initialized string don you"

Those things were variable names. You never put variable names in quotes because a String value and a variable name are completely different things.
You got the "not initialised" message because you declared the variable usergrde on line 28 but you never initialised it by giving it any value, so when you tried to use it in your if tests it was still null.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.