0% found this document useful (0 votes)
33 views

Grading System

This Java program creates a grading system GUI that allows a user to input preliminary and midterm exam scores, calculates the grade as 20% of each score added together, and displays the grade report. The program extends JFrame and implements ActionListener. It contains labels, text fields and buttons to get the input scores and perform the grade calculation when the "Compute" button is clicked. The grade is displayed in the labels when computed. The "Clear" button resets the text fields and labels.

Uploaded by

Vinz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views

Grading System

This Java program creates a grading system GUI that allows a user to input preliminary and midterm exam scores, calculates the grade as 20% of each score added together, and displays the grade report. The program extends JFrame and implements ActionListener. It contains labels, text fields and buttons to get the input scores and perform the grade calculation when the "Compute" button is clicked. The grade is displayed in the labels when computed. The "Clear" button resets the text fields and labels.

Uploaded by

Vinz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

import javax.swing.

*;
import java.awt.event.*;

public class GradingSystem extends JFrame implements ActionListener {

JTextField pre = new JTextField(10);


JTextField mid = new JTextField(10);

JButton Compute = new JButton("Compute");


JButton Clear = new JButton("Clear");

JLabel grade = new JLabel();


JLabel report = new JLabel();

double solve = 0.00;

double prelim=0.00,midterm=0.00;

public GradingSystem() {

super("Grade Computation");
setSize(240,240);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

JPanel pane = new JPanel();

JLabel prelim_label = new JLabel(" Prelim ");


JLabel midterm_label = new JLabel(" Midterm ");

pane.add(prelim_label);
pane.add(pre);

pane.add(midterm_label);
pane.add(mid);

pane.add(Compute);
pane.add(Clear);

Compute.addActionListener(this);
Clear.addActionListener(this);
Compute.setToolTipText("Click here to compute the grade.");
Clear.setToolTipText("Click here to clear text fields.");

pane.add(report);
pane.add(grade);

add(pane);

setVisible(true);
}

public void actionPerformed(ActionEvent e)


{

if(Compute==e.getSource())
{
prelim=Double.parseDouble(pre.getText()) * 0.2;
midterm=Double.parseDouble(mid.getText()) * 0.2;

solve = (prelim + midterm);

report.setText(" === Grade Report === ");


grade.setText("Student Grade is "
+String.format("%.0f",solve)+".");

if(Clear==e.getSource())
{
pre.setText("");
mid.setText("");

report.setText("");
grade.setText("");

}
}

public static void main(String [] args)


{
GradingSystem grade = new GradingSystem();
}
}

You might also like