This site requires JavaScript, please enable it in your browser!
Greenfoot back
divinity
divinity wrote ...

2016/1/17

how should acquire the correct gpa and output

divinity divinity

2016/1/17

#
hi all I have been trying to do this program for a while now. i need to get the program to calculate the quality point in order for me to get the correct grade and gpa. I know there is something that I may not be calculating some where. in the calculation you have to do this After acquiring the pertinent information from the student, the program MUST then calculate the student GPA. The TOTAL number of quality points earned for the semester divided by the TOTAL number of credits earned will yield a student semester GPA. Quality points for EACH course is calculated by multiplying the GRADE VALUE assigned to the grade for that course by the number of credits for the course. (Example, If a student gets an ‘A’ in a course(ITEC133) and the credit given to that course is (3) then the Quality Points for the said course would equate to 12 (4 (grade value) X 3 ( credit) ) Grade Grade Code Grade Description marks % Grade Point Value A 1 Excellent 90-100 4 B+ 2 Very Good 85-89.9 3.5 B 3 Good 80-84.9 3.0 C+ 4 Satisfactory 75-79.9 2.5 C 5 Average 70-74.9 2 D+ 6 Below Average 65-69.9 1.5 D 7 Minimum Passing Grade 60-69.9 1 D 8 Failure 0.0-59.9 0 some how you have to link the table in order to get the required gpa and to get the grades received. here is what i have so far. dont know what i am doing wrong. here because am not getting the required output
public static int calQualityPoints( int credits, int qualitypoints)
    {
        int  num_credits=0, total=0,total_pts=0, points=0, gpa=0;
        
        double grdevalue=0;
        
       char grde ='A';
        
        if(grde >=90 )
        {
            System.out.println("you grade is a A");
            grdevalue = 4;
        }
        else if(grde >=85 ||grde <= 89.5)
        {
            System.out.println(" your grade is B+");
            grdevalue = 3.5;
        }
        else if(grde >=80 ||grde >=84.9)
        {
            System.out.println("your grade is: B+");
            grdevalue = 3.0;
        }
        else if(grde >=75 || grde <=79.9)
        {
            System.out.println("your grade is: C+");
            grdevalue = 2.5;
        }
        else if(grde >= 70 || grde >=74.9)
        {
            System.out.println("your grade is: C");
            grdevalue = 2;
        }
        else if(grde >=65 || grde <= 69.9)
        {
            System.out.println("your grade is: D+");
            grdevalue = 1.5;
        } 
        else if(grde >= 60 || grde <= 64.9)
        {
            System.out.println("your grde is: D");
            grdevalue = 1;
        }
        else if(grde >= 0.0 || grde <= 59.9)
        {  
            System.out.println("you failed");
            grdevalue = 0;
            
            total += grdevalue * credits;
            total_pts = points * num_credits;
            gpa = total_pts / num_credits;
            System.out.println("the gpa for the semester is "+ gpa);
        }
        return gpa;
       
    }
    
  
    public static int calGpa(int grdevalue, int num_ofcredits)
    {
        int totalpoints;
        int gpa=0, qualitypoints=0;
        
        totalpoints = qualitypoints / num_ofcredits;
        
        return qualitypoints;
        
    }
    public static void main(String[] args) 
    {
             Scanner userinput = new Scanner(System.in);
        
            int i, num_courses=0, totalqpts, gparec;
            int num_ofgrades=0;
            String grde ="" ;
            int gpa =0;
            String courses="";
            

            int num_course[] = new int[num_courses];
            int grades[]= new int [num_ofgrades];
        
        
            
        
                System.out.println("hi enter the student id number");
                String idnum = userinput.next();

                System.out.println("hi enter the student first name");
                String firstname = userinput.next();

                System.out.println("hi enter the student last name");
                String lastname = userinput.next();

                System.out.println("hi enter the academic year");
                int academic_year = userinput.nextInt();

                System.out.println("hi enter the semester number");
                int semester_num = userinput.nextInt();

                System.out.println("hi how many courses taken");
                num_courses = userinput.nextInt();



                System.out.println("enter your course code");
                String course_code = userinput.next();

                System.out.println("enter the course credit");
                int course_credit = userinput.nextInt();

                System.out.println("what is the grade code receive");
                int grde_code = userinput.nextInt();

                /*totalqpts = calQualityPoints(credits, qualitypoints); (when calling the method here am getting a syntax error 
                gparec = calGpa(grdevalue, num_credits);*/

                System.out.println("the student id is "+idnum);
                System.out.println("the student first and last name is "+ firstname + lastname);
                System.out.println("the student semester number is "+ semester_num);
                System.out.println("the academic year is "+ academic_year);
                System.out.println("the number of course taken is "+ num_courses);
                System.out.println("the grades recieve is "+ grde);
                System.out.println("the gpa receive is "+ gpa);


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

                System.out.println("student name: "+firstname+lastname);
                System.out.println("student id: "+idnum);
                
                System.out.println("                    ");

                System.out.println("academic year:"+academic_year);
                System.out.println("semester no:"+semester_num);
                
                System.out.println("                               ");

                System.out.println("courses pursued: "+courses);
                
                System.out.println("                            ");

                System.out.println("course code: "+course_code);
                System.out.println("grade received:"+grde);
                
                System.out.println("                        ");

                System.out.println("gpa:"+gpa);
               
danpost danpost

2016/1/17

#
There are so many issues with the code given, it is hard to determine where to start. With the 'calQualityPoints' method alone: (1) its name implies that a quality point value will be returned; however, it returns a gpa value; and, besides that, has a parameter that appears to be the quality points value to begin with; (2) it compares the 'char' value of 'grde' to literal 'double' values (grade percentage values); (3) it declares fields (like 'num_credits',, 'total', 'total_pts', and 'gpa') that you need to sustain for more than a single execution of the method; these field values will be initialized every time the method is called. These fields need to be declared in the 'main' method and the other methods should only declare temporary variables (only one value can be maintained beyond the execution of other methods -- the one value that they each return). I see you are getting input for the number of courses taken; yet, you are getting information about just one of them beyond that.
divinity divinity

2016/1/17

#
so how do i correct that
danpost danpost

2016/1/18

#
divinity wrote...
so how do i correct that
You can introduce a loop structure to input the information for all courses taken. First, of course, you will need to move most of your fields into the 'main' method (any field whose value is to maintained beyond the call of another method).
You need to login to post a reply.