0

tell me if my codes is correctly done in calculating the gpa and the quality points and calling the methods for the gpa and quality points because my output is reading zero.
i have also to write two arrays to store both the students grades and course. have no idea on how to start yet and I have to hand this in midnight. here is my codes

public static double calGpa(double totqpts, double totcred) 
    {
        double gpa,totqpt = 0 ;
        double grdenum = 0;
        int totcreds = 0;

        totqpts = totcreds * grdenum;
        gpa = totqpts / totcreds;


        return gpa;

      }

       public static double calQualityPoints(double gvp, double qpt) 
       {

        double gvlp, qpts = 0;

             double grdeval,totalcred;


          if("grde".equals("A"))
           {
               grdeval = 4 * 3;
           }
           else if ("grde".equals("B+"))
           {
               grdeval = 3.5 * 3;
           }
           else if("grde".equals("B"))
           {
               grdeval = 3.0 * 3;
           }
           else if("grde".equals("C+"))
           {
               grdeval = 2.5 *3;
           }
           else if("grde".equals("C"))
           {
               grdeval = 2 * 3;
           }
           else if("grde".equals("D+"))
           {
               grdeval = 1.5;
           }
           else if("grde".equals("D"))
           {
               grdeval = 1*3;
           }
           else if("grde".equals("F"))
           {
               System.out.println("you are on academic probation");

           }
          return qpts;

 }

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

            String  username;
            int stuidnum, courses= 0;
            int acyear, semester = 0;  
            int semesterno = 2;
            int numcourses, counter;
            String coursecode;
            int coursecred, gpa = 0;
            int grdesrec =0; 
            int totcred = 0 ;
            double qpts =0, grdepts;
            double gpacal, cqpts;
            int grde = 0;
            double grdeval = 0, gvp = 0;
            double totqptsc1,totqptsc2,totqptsc3;
            int grdecode, totqpts =0;

            System.out.println("please enter the student first name and last name ");// prompt for student first name
            username = kbd.next();

            System.out.println("please enter student id number"); //prompt for student id number
            stuidnum = kbd.nextInt();

            System.out.println("please enter academic year");// generate the academic year
            acyear = kbd.nextInt();

            System.out.println("please enter semester number");//prompt for the number of semester
            semesterno = kbd.nextInt();

            System.out.println("please enter the number of courses taken");// asking for the number of course will be taken
            numcourses = kbd.nextInt();
            //prompting for student information-.

            // prompting for the course informtion below
            System.out.println("please enter your course code");// need course code
            coursecode = kbd.next();

            //prompt to ask for course credits
            System.out.println("please enter course credit");// neesd the course credit
            coursecred = kbd.nextInt();

            //ask for their grades recieved
            System.out.println("please enter the grade code received in the course");// need grade
            grdecode=kbd.nextInt();

            cqpts = calQualityPoints(gvp, qpts);
            gpacal = calGpa(totqpts,totcred);


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


            System.out.println("the student name is " + username );
            System.out.println("the student id number is " + stuidnum);
            System.out.println("the semester number is " + semesterno);
            System.out.println("the academic year is " + acyear);
            System.out.println("the number of course done " + numcourses);
            System.out.println("the grades received is " + grdesrec);
            System.out.println("the gpa for the academic year");
            //output the information ask for

            System.out.println("                                     ");

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

            System.out.println("the student name is " + username);
            System.out.println("the student id number is " + stuidnum);
            System.out.println("courses pursued");
            System.out.println("the courses pursued  are " + courses);
            System.out.println("the grde is " + grde);
            System.out.println("the gpa is " + gpa );
            System.out.println("the academic year is " + acyear);
            System.out.println("the semester is " + semester);


        }

    }

        here is the output. 
        run:
please enter the student first name and last name 
kestonpendleton
please enter student id number
00027855
please enter academic year
2015
please enter semester number
2
please enter the number of courses taken
3
please enter your course code
itec133
please enter course credit
3
please enter the grade code received in the course
3
------------------------------------
the student name is kestonpendleton
the student id number is 27855
the semester number is 2
the academic year is 2015
the number of course done 3
the grades received is 0
the gpa for the academic year

***********ACADEMIC TRANSCRIP****************
the student name is kestonpendleton
the student id number is 27855
courses pursued
the courses pursued  are 0 - tell me why I am getting a zero here
the grde is 0 - tell me why am i getting a zero here also 
the gpa is 0 here also 
the academic year is 2015
the semester is 0 = here also
BUILD SUCCESSFUL (total time: 39 seconds)

need an answer as soon as possible. this have to be hand in by midnight. the quick the answer so that i can work on it.

2
Contributors
1
Reply
17
Views
1 Year
Discussion Span
Last Post by stultuske
0

You are working with local variables which you don't update.

from within your main method, I copied this and kept only the lines handling those variables.

            int stuidnum, courses= 0;
            int grde = 0;

            System.out.println("courses pursued");
            System.out.println("the courses pursued  are " + courses);
            System.out.println("the grde is " + grde);

so, you declare two variables, initialize them to the value 0, and never change the value. That's why they print out 0.

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.