Software is being developed by a university that displays SGPA of your current semester. You are given the task to develop a module that calculates the SGPA with respect to the secured grade points corresponding to given number of credits in each subject. The credits for the courses are: Graphics: 2, PPS: 4, JAVA: 3, Chemistry: 3, English: 2, Technical Skills: 1.5, Data Structures: 4 Complete your Module by displaying the SGPA of current semester.

 /* Caluculating */

import java.util.*;

class SGPA_Cal_S_2A

{

    public static void main(String[] args)

    {

Scanner s = new Scanner(System.in);

double SGPA,total=0,sum=0;

int gp=0,i;

String grade;

String subjects[]={"Graphics","PPS","JAVA","Chemistry","English","TechnicalSkills","Data Structures"};

double Credits[]={2,4,3,3,2,1.5,4};


for(i=0;i<subjects.length;i++)

{

      System.out.print("Enter "+subjects[i]+" Grade : ");

      grade = s.next();

      switch(grade)

      {

case "A+":gp=10; break;

case "A": gp=9; break;

case "B": gp=8; break;

case "C": gp=7; break;

case "D": gp=6; break;

case "E": gp=5; break;

case "F": gp=0; break;

default: System.out.println("Wrong Grade.");

  i--;

      }

      if(gp==0)

      {

break;

      }

      total += gp * Credits[i];

      sum += Credits[i];

}

if(gp==0)

{

     System.out.println("Student Failed in Exam");

}

else

{

     SGPA = total/sum;

     System.out.println("SGPA is : "+String.format("%.2f",SGPA));

}

    }

}


Comments

Popular posts from this blog

Design GUI to handle Choice Control event.

Write a Java program that reads an integer number (between 1 and 255) from the user and prints the binary representation of the number. The answer should be printed as a String. Note: The output displayed should contain 8 digits and should be padded with leading 0s(zeros), in case the returned String contains less than 8 characters. For example, if the user enters the value 16, then the output should be 00010000 and if the user enters the value 100, the output should be 01100100 (Hint : You may use String.format() method for the expected output)