Subscribe For Free Updates!

We'll not spam mate! We promise.

Monday, 27 August 2012

Java code to find CGPA



import java.util.Scanner;
class cgpa
{
public static void main(String arg[])
{
cgpa gpa=new cgpa();
//gpa.gpaOne();
System.out.println("\n\nYour CGPA is =  "+gpa.gpaOne()+" \n\n");
}
private double gpaOne()
{
double ItpGpa=0,EngGpa=0,CalGpa=0,IslmGpa=0,IntroGpa=0;
double CrdtHour=17,TotlaCgpa=0;
String Itcp,Eng,Calculus,Islamic,Intro;
Scanner sc=new Scanner(System.in);
// input ITCP Grade
System.out.print("Enter Grade of ITCP: ");
Itcp=sc.next();
// input English Grade
System.out.print("Enter Grade of English: ");
Eng=sc.next();
// input Calculus Grade
System.out.print("Enter Grade of Calculus: ");
Calculus=sc.next();
System.out.print("Enter Grade of Islamic Studies: ");
Islamic=sc.next();
System.out.print("Enter Grade of Intr to Computing: ");
Intro=sc.next();

/// Calculation of English GPA

if (Itcp.equals("A")||Itcp.equals("a"))
{
ItpGpa=4.0;
}
else if (Itcp.equals("A-")||Itcp.equals("a-"))
{
ItpGpa=3.7;
}
else if (Itcp.equals("B+")||Itcp.equals("b+"))
{
ItpGpa=3.5;
}
else if (Itcp.equals("B")||Itcp.equals("b"))
{
ItpGpa=3.0;
}
else if (Itcp.equals("C+")||Itcp.equals("c+"))
{
ItpGpa=2.5;
}
else if (Itcp.equals("C")||Itcp.equals("c"))
{
ItpGpa=2.0;
}
else if (Itcp.equals("D+")||Itcp.equals("d+"))
{
ItpGpa=1.5;
}
else if (Itcp.equals("D")||Itcp.equals("d"))
{
ItpGpa=1.0;
}
else if (Itcp.equals("F")||Itcp.equals("f"))
{
ItpGpa=0.0;
}
System.out.println("Your CGPA is =  "+ItpGpa);

/// Calculation of English GPA
if (Eng.equals("A")||Eng.equals("a"))
{
EngGpa=4.0;
}
else if (Eng.equals("A-")||Eng.equals("a-"))
{
EngGpa=3.7;
}
else if (Eng.equals("B+")||Eng.equals("b+"))
{
EngGpa=3.5;
}
else if (Eng.equals("B")||Eng.equals("b"))
{
EngGpa=3.0;
}
else if (Eng.equals("C+")||Eng.equals("c+"))
{
EngGpa=2.5;
}
else if (Eng.equals("C")||Eng.equals("c"))
{
EngGpa=2.0;
}
else if (Eng.equals("D+")||Eng.equals("d+"))
{
EngGpa=1.5;
}
else if (Eng.equals("D")||Eng.equals("d"))
{
EngGpa=1.0;
}
else if (Eng.equals("F")||Eng.equals("f"))
{
EngGpa=0.0;
}
System.out.println("Your CGPA is =  "+EngGpa);

/// Calculation of Calculus GPA

if (Calculus.equals("A")||Calculus.equals("a"))
{
CalGpa=4.0;
}
else if (Calculus.equals("A-")||Calculus.equals("a-"))
{
CalGpa=3.7;
}
else if (Calculus.equals("B+")||Calculus.equals("b+"))
{
CalGpa=3.5;
}
else if (Calculus.equals("B")||Calculus.equals("b"))
{
CalGpa=3.0;
}
else if (Calculus.equals("C+")||Calculus.equals("c+"))
{
CalGpa=2.5;
}
else if (Calculus.equals("C")||Calculus.equals("c"))
{
CalGpa=2.0;
}
else if (Calculus.equals("D+")||Calculus.equals("d+"))
{
CalGpa=1.5;
}
else if (Calculus.equals("D")||Calculus.equals("d"))
{
CalGpa=1.0;
}
else if (Calculus.equals("F")||Calculus.equals("f"))
{
CalGpa=0.0;
}
System.out.println("Your CGPA is =  "+CalGpa);

/// Calculation of Islamic GPA

if (Islamic.equals("A")||Islamic.equals("a"))
{
IslmGpa=4.0;
}
else if (Islamic.equals("A-")||Islamic.equals("a-"))
{
IslmGpa=3.7;
}
else if (Islamic.equals("B+")||Islamic.equals("b+"))
{
IslmGpa=3.5;
}
else if (Islamic.equals("B")||Islamic.equals("b"))
{
IslmGpa=3.0;
}
else if (Islamic.equals("C+")||Islamic.equals("c+"))
{
IslmGpa=2.5;
}
else if (Islamic.equals("C")||Islamic.equals("c"))
{
IslmGpa=2.0;
}
else if (Islamic.equals("D+")||Islamic.equals("d+"))
{
IslmGpa=1.5;
}
else if (Islamic.equals("D")||Islamic.equals("d"))
{
IslmGpa=1.0;
}
else if (Islamic.equals("F")||Islamic.equals("f"))
{
IslmGpa=0.0;
}
System.out.println("Your CGPA is =  "+IslmGpa);

/// Calculation of Inrto to Computing GPA

if (Intro.equals("A")||Intro.equals("a"))
{
IntroGpa=4.0;
}
else if (Intro.equals("A-")||Intro.equals("a-"))
{
IntroGpa=3.7;
}
else if (Intro.equals("B+")||Intro.equals("b+"))
{
IntroGpa=3.5;
}
else if (Intro.equals("B")||Intro.equals("b"))
{
IntroGpa=3.0;
}
else if (Intro.equals("C+")||Intro.equals("c+"))
{
IntroGpa=2.5;
}
else if (Intro.equals("C")||Intro.equals("c"))
{
IntroGpa=2.0;
}
else if (Intro.equals("D+")||Intro.equals("d+"))
{
IntroGpa=1.5;
}
else if (Intro.equals("D")||Intro.equals("d"))
{
IntroGpa=1.0;
}
else if (Intro.equals("F")||Intro.equals("f"))
{
IntroGpa=0.0;
}
System.out.println("Your CGPA is =  "+IntroGpa);
/// Calculatoon With Credit Hours each Subject..
ItpGpa*=4;
EngGpa*=3;
CalGpa*=3;
IslmGpa*=3;
IntroGpa*=4;
return TotlaCgpa=((ItpGpa+EngGpa+CalGpa+IslmGpa+IntroGpa)/CrdtHour);
//System.out.println("\n\n");
//System.out.println("Your CGPA is =  "+TotlaCgpa+" \n\n");
}
}

Socializer Widget By CodingLovers
SOCIALIZE IT →
FOLLOW US →
SHARE IT →

4 comments:

  1. Nice tutorial. Thanks for sharing the valuable information. it’s really helpful. Who want to learn this blog most helpful. Keep sharing on updated tutorials…
    Best Devops Training in pune
    Microsoft azure training in Bangalore

    ReplyDelete

  2. It seems you are so busy in last month. The detail you shared about your work and it is really impressive that's why i am waiting for your post because i get the new ideas over here and you really write so well.

    Selenium training in Chennai
    Selenium training in Bangalore
    Selenium training in Pune
    Selenium Online training
    Selenium training in bangalore

    ReplyDelete
  3. My rather long internet look up has at the end of the day been compensated with pleasant insight to talk about with my family and friends.

    python training in rajajinagar
    Python training in bangalore
    Python training in usa

    ReplyDelete