Grade Computation in Java

Grade Computation in Java
  • Version
  • Download 190
  • File Size 3.38 KB
  • Create Date May 10, 2016

Grade Computation in Java

Example program in java that computes your final grade based on your prelim, midterm and endterm grades. It is a sort of averaging program but the e grades (prelim, midterm and endterm) does not share equal percentages; the equation for the final grade will be 30% of the prelim grade, 30% of the midterm grade and 40% of the endterm grade.

Source code:

import javax.swing.*;
public class GradeComputationGUI
{ 
public static void main(String args[]) {

String input1,input2,input3;
double prelim, midterm, finals ; 
double result=0;
String cont="n";

do
{
	
input1 = JOptionPane.showInputDialog(null,"enter prelim grade: ");
prelim=Double.parseDouble(input1);	
	
input2 = JOptionPane.showInputDialog(null,"enter midterm grade: ");
midterm=Double.parseDouble(input2);

input3 = JOptionPane.showInputDialog(null,"enter midterm grade: ");
finals=Double.parseDouble(input3);

result= (prelim * 0.30) + (midterm * 0.30) + (finals * 0.40);

JOptionPane.showMessageDialog(null,"Final Grade: " + result  );

	cont =	JOptionPane.showInputDialog(null,"Try Again? (press y or n) ");
	}while (cont.matches("y"));

JOptionPane.showMessageDialog(null,"Program closing"  );


	}
}
, , , , , ,

Post navigation

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.