Information and study is a popular blog of programming languages (C,C++,java),Data structure and algorithms, object oriented programming, and interviewing questions for fresher's. This blog is essential for software engineers and developers.
Program to Calculate GPA and CGPA in java
How to calculate GPA and CGPA in java?
import java.util.*;
public class CGPA_3rd_Semster
{
public static void main(String[] args)
{
Scanner obj = new Scanner(System.in);
double ds,eng,discrete,network,hrm;
System.out.print("\t\t***___Created By Jhangir Mughal___***");
System.out.print("\n\nEnter Data Structure Gpa:> ");
ds=obj.nextFloat();
System.out.print("Enter Discrete Structure Gpa:> ");
discrete=obj.nextFloat();
System.out.print("Enter Network Gpa:> ");
network=obj.nextFloat();;
System.out.print("Enter HRm Gpa:> ");
hrm=obj.nextFloat();
System.out.print("Enter Critical Reading and Academic Writing Gpa:> ");
eng=obj.nextFloat();
double gpads,gpaeng,gpadis,gpanet,gpahr;
gpads=ds*4;
gpaeng=eng*3;
gpadis=discrete*3;
gpanet=network*3;
gpahr=hrm*3;
double totalGpa,tcredhr=16;
totalGpa=gpads+gpaeng+gpadis+gpanet+gpahr;
double finalGpA;
finalGpA=totalGpa/tcredhr;
System.out.print("\nYour Gpa Is:> " +finalGpA);
double Gpa1st,credhr1st;
System.out.print("\n\nEnter your First Semester Gpa:> ");
Gpa1st=obj.nextFloat();
System.out.print("Enter your 1st Semester Credit Hours:> ");
credhr1st=obj.nextFloat();
double Gpa2nd, credhr2nd;
System.out.print("\n\nEnter your 2nd Semester Gpa:> ");
Gpa2nd=obj.nextFloat();
System.out.print("Enter your 2nd Semester Credit Hours:> ");
credhr2nd=obj.nextFloat();
double firstSem,secSem,thirdSem;
firstSem=credhr1st*Gpa1st;
secSem=credhr2nd*Gpa2nd;
thirdSem=tcredhr*finalGpA;
double CGPA_2ndsem,T3rd_CGPA;
CGPA_2ndsem=(firstSem+secSem)/(credhr1st+credhr2nd);
System.out.print("\nYour CGPA in 2nd semester:> "+CGPA_2ndsem);
T3rd_CGPA=(firstSem+secSem+thirdSem)/(credhr1st+credhr2nd+tcredhr);
System.out.print("\n\nYour CGPA in 3rd semester:>>> "+T3rd_CGPA);
}
}
Output:
Program to Calculate GPA and CGPA in C++?
Write a program in C++ using switch statement
Searching Algorithms in Data Structure
Sorting Algorithms in Data Structure
Queue Data Structure Theory and Program in java
Stack Data Structure Theory and Program in java