i am doing this gpa java program where I have to implement two method, one called calgpa and the next calqualitypoints, and i have also have to put in two java arrays one for the numbers of courses and the other for whats graded 

the problem my program is giving me a runtime error and ah cyah seem to figure out how, why and where 

here is the program

public static int calGpa(int totalcredit, int totalqpt) 
    {
            int totalnumqpts = 0, totalnumcredits = 0, gpa;

            gpa = (totalnumqpts / totalnumcredits);

            return gpa;
    }
    public static double calQualityPoints (double qpt) 
    {
        double  usercode = 0, qpts = 0;  

        if(usercode == 1)
        {
            qpts = 4 * 3;
        }
        else if(usercode == 2)
        {
            qpts = 3.5 * 3;
        }
        else if(usercode == 3)
        {
            qpts = 3.0 * 3;
        }
        else if(usercode == 4)
        {
            qpts = 2.5 * 3;
        }
        else if(usercode == 5)
        {
            qpts = 2 * 3;
        }
        else if(usercode == 6)
        {
            qpts = 1.5 * 3;
        }
        else if(usercode == 7)
        {
            qpts = 1* 3;
        }
        else if(usercode == 8)
        {
            qpts = 0 * 3;

        }
        return qpts;
    }
        //implementing methods

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


            String studfirstname, studlastname;
            int studidnum;
            int acyear,  grde =0;
            int semesterno = 2;
            int numcourses, counter;
            String coursecode;
            int coursecred, gpa = 0;
            int grdesrec =0;
            double totalcred = 0 ;
            int grdecode, qpts =0, grdepts, totalcredits = 0, totalqpt =0;
            double gpacal, cqpts;

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

            System.out.println("please enter student id number"); //prompt for student id number
            studidnum = 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(); this is where the program would stop and ah wud get the runtime error
            //prompting for student information-.

            //calculation

            gpacal=calGpa(totalcredits,totalqpt); did I called the method correctly is the calculation wrong  or something 
            cqpts = calQualityPoints (qpts); this is where I would get a runtime error


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

much thank for the help
so I am wondering if i did the method calculation wrong
did i called the method correctly
what is the correct way to implement array into this program. this is what i have to do

Hi divinity02
I think you have been around DaniWeb long enmough now to know IF YOU HAVE A RUNTIME ERROR, POST THE ERROR MESSAGE!!!

sorry j will do in a while

run:
please enter the student first name and last name 
kw
please enter student id number
00027855
please enter academic year
2015
please enter semester number
2
please enter the number of courses taken
3
Exception in thread "main" java.lang.ArithmeticException: / by zero
    at luana_gpa.Luana_gpa.calGpa(Luana_gpa.java:18)
    at luana_gpa.Luana_gpa.main(Luana_gpa.java:97)
Java Result: 1
BUILD SUCCESSFUL (total time: 17 seconds)

this is the runtime error am gettinh

OK, that's better. The line numbers do not match your post, but I guess line 18 is

gpa = (totalnumqpts / totalnumcredits);

in which case totalnumcredits must be zero, you probably forgot to maintain or calculate that.

why do i have to initialize usercode

You have to initialise every variable before you use it.

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.