How to write a java program to calculate CGPA percentage.
How to write a java program to calculate
CGPA percentage. Java code to calculate the
CGPA ( Cumulative Grade Point
Average ), in 5 different ways. Using
standard values, using command line
arguments, inputs through scanner class
and user define method. Cumulative Grade
Point Average ( CGPA ) is overall grade
point average. Definition and sample
programs are described below about GPA.
Check more programs for beginners and
interview question and answers here.
Sr .No Program | 3 Ways
1. Using Standard Values
2. Using Command Line Arguments
3. Using Method Invoking
What is CGPA ?
A: CGPA is overall grade point average. For
each course there are certain credits which
is usually based on how many hours the
class is held in each week.
How to calculate the CGPA and formula ?
A: Your grade point average ( GPA ) is
calculated by dividing the total amount of
grade points earned by the total amount of
credit hours attempted. Your grade point
average may range from 0.0 to a 4.0. To get
the example student’s GPA , the total grade
points are divided by the total credit hours
attempted. Here is the simple formula to
calculate the GPA ( Grade point average
formula )
Calculate GPA – Java
Program In Five Ways
Program To Find CGPA – 1 ( Using
standard values with outputs )
Here we wrote the code with standard
values. We also embedded a online
execution tool below do check it out.
Standard values are nothing but using the
above formula to find the GPA in the below
program. For, every code we added three to
four different types of outputs so that you
will get an idea.
Java Code using a standard values here.
Output:
Sample Program GPA – 2 ( Using
Command Line Arguments )
Here we go another program using
command line arguments . If you have no
idea bout command line arguments check
out here: Complete guide. In simple
command lines are nothing but giving
inputs on console it itself. Check out the
code and output.
Output ( Using command line
arguments ) :
Calculate GPA Using Arrays
Here we go another method to calculate a
grade point average, taking inputs through
scanner class method.
Output ( Inputs Through Scanner Class ):
Java Program By Using Method
Java code for calculating CGPA using a user
defined method with sample outputs and
execution tool. Check it out!
Output ( User define method ) :
Sample Program – 5 (using class)
Here we go another version of program to
calculate the GPA by creating a new
separate class for ( CGPAcalculation) and
taking inputs using scanner class method
with sample outputs.
Output:
More Tutorials :
Do while in java with examples
Java Switch Case Statement Tutorial And
Examples
Java Datatypes Tutorial And Examples
Java Command Line Arguments Examples
Sorry, the browser you are using is not
currently supported. Disqus actively
supports the following browsers:
Firefox
Chrome
Internet Explorer 11+
Safari
ABOUT SEMLEAP DIGITAL MEDIA PVT.LTD
©Semleap Digital Media Private Limited :
JavaTutoring site was created and maintained
by SEMleap. We are proud to say that this is
our first project which got a huge repsonse
from Java Programming fans. For any
information you can contact us here at :
admin@javatutoring.com
CATEGORIES
Areas
Beginners Programs
Control Statements
Java Tutorials
Loops
Uncategorized
JAVA TUTORIALS
Java Switch Case Statement :
Tutorial With Examples – Java
Tutoring
December 2, 2016
Java Switch Case , generally
used for one out of […]
Java Break – Tutorial For
Beginners
January 1, 2017
Java break statement complete
tutorial for beginners […]
Java Operators – Beginners
Guide With Examples
August 10, 2016
Java operators, and order of
operations. The following […]
Java Do While Loop With
Examples – Java Tutoring
December 1, 2016
Do while in Java Everything you
need to know about […]
Java For Loop – Tutorial With
Examples | Loops
May 13, 2017
Java for loop tutorial with
examples and complete […]
Command Line Arguments In Java With
Examples | Tutorials
July 31, 2016
Command line arguments is a methodology
which user […]
Data Types In Java – With
Examples
August 8, 2016
Data types in Java, primitive
types, Java environment […]
Java Hashmap – Tutorial With
Examples
December 26, 2016
Java hashmap a complete
tutorial for beginners with […]
Java Variables – Tutorial With Examples
April 20, 2017
Java variables are nothing but a similar way
we use a […]
class CGPA
{
public static void main (String ar
{
int n =5 ;
double m [] =new double [n ];
double g [] =new double [n ];
double cgpa , sum= 0 ;
m [0 ] = 95;
m [1 ] = 85;
m [2 ] = 75;
m [3 ] = 80;
m [4 ] = 95;
for( int i =0 ; i < n; i ++ )
{
g [ i ] =( m [ i ]/ 10 );
}
for( int i =0 ; i < n; i ++ )
{
sum+= g [ i];
}
cgpa = sum/ n;
System. out. println( "cgpa=" + cgp
System. out. println( "percantage
}
}
Output
cgpa=8.6
percantage from cgpa=81.7
Comments