metaBeta
About Us

Leader:Muhammad Affiq Bin Mohd Rashid
Date of Birth: 19 May 1987
Matriks No: UK12912
e-mail:sonic_danger87@yahoo.com






Khairul Azhar Bin Jaafar Sidek
Date of Birth: 07 December 1987
Matriks No: UK13082
e-mail: idontloveyou87@yahoo.co.uk






Mohamad Zahary Bin Ahmad Khabri
Date of Birth: 24 June 1987
Matriks No: UK13242
e-mail: intoxicated_candle@yahoo.com






Afeez Bin Muri
Date of Birth: 19 February 1987
Matriks No: UK13643
e-mail: gemang87@yahoo.com

Thursday, January 17, 2008

coding for calculating gpa

import javax.swing.*;
public class Calculator{
public static void main (String [] args)
{ String gred, ulang, input;
int count, kredit;
double points, point1, point2, totalkredits, GPA, totalPoints;
do
{
gred = JOptionPane.showInputDialog( "Enter your letter grade" );
points = 0.00;
totalPoints = 0.00;
totalkredits = 0.00;
do {
input = JOptionPane.showInputDialog( "Enter your number of kredits? 1-6" );
kredit = Integer.parseInt( input );
if ((kredit<1)>6)) {
JOptionPane.showMessageDialog( null, "-----------------------------------------------------------------\nERROR\n\n----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----\nYOU MUST ENTER A NUMBER FROM 1 TO 6"); } }
while ((kredit<1)>6));
{ if (gred.equalsIgnoreCase("A"))
points = 4.00 * kredit;
} { if (gred.equalsIgnoreCase("A-"))
points = 3.75 * kredit;
} { if (gred.equalsIgnoreCase("B+"))
points = 3.50* kredit;
}{ if (gred.equalsIgnoreCase("B"))
points = 3.00 * kredit;
}{ if (gred.equalsIgnoreCase("B-"))
points = 2.75 * kredit;
}{ if (gred.equalsIgnoreCase("C+"))
points = 2.50 * kredit;
}{ if (gred.equalsIgnoreCase("C"))
points = 2.00 * kredit;
}{ if (gred.equalsIgnoreCase("C-"))
points = 1.75 * kredit;
} { if (gred.equalsIgnoreCase("D"))
points = 1.00 * kredit;
}{ if (gred.equalsIgnoreCase("F"))
points = 0.00 * kredit;
} totalPoints += points;
totalkredits += kredit;
ulang = JOptionPane.showInputDialog("Would you like to enter another class grade? Yes or NO"); }while (ulang.equalsIgnoreCase("YES"));
if (ulang.equalsIgnoreCase("NO")) {
GPA = totalPoints/totalkredits;
JOptionPane.showMessageDialog( null, (" You have a GPA of " + GPA));
System.exit(0); }
} }

0 comments: