Hi everyone!
If anyone knows how to solve this, please help me... I'm currently a newbie in java.
I want to add a remarks to the student grade, i want the remarks to display in the Jtextfield that i added.. thank you
1.0 98-100 Outstanding
1.25 95-97 Very Satisfactory
1.5 92-94 Very Satisfactory
1.75 89-91 Satisfactory
2.0 86-88 Satisfactory
2.25 83-85 Satisfactory
2.5 80-82 Satisfactory
2.75 77-79 Passing
3.0 75-76 Passing
below 3.0 <=74 failed
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class StudentPerformance extends JFrame
{
private static final int width = 400;
private static final int height = 300;
private JLabel studentnameL, courseL, yearL, quizgradeL, attendancegradeL, projectgradeL, examgradeL, finalgradeL, equivalentgradeL, remarksL;
private JTextField studentnameTF, courseTF, yearTF, quizgradeTF, attendancegradeTF, projectgradeTF, examgradeTF, finalgradeTF, equivalentgradeTF, remarksTF;
private JButton ExitB, CalculateB;
private CalculateButtonHandler cbHandler;
private ExitButtonHandler ebHandler;
public StudentPerformance()
{
setTitle("StudentPerformance");
studentnameL = new JLabel("Enter Student Name", SwingConstants.LEFT);
courseL = new JLabel("Enter Student Course", SwingConstants.LEFT);
yearL = new JLabel("Enter Student Year", SwingConstants.LEFT);
quizgradeL = new JLabel("Enter Quiz Grade", SwingConstants.LEFT);
attendancegradeL = new JLabel("Enter Attendance Grade", SwingConstants.LEFT);
projectgradeL = new JLabel("Enter Project Grade", SwingConstants.LEFT);
examgradeL = new JLabel("Enter Exam Grade", SwingConstants.LEFT);
finalgradeL = new JLabel("Final Grade is", SwingConstants.LEFT);
equivalentgradeL = new JLabel("Equivalent grade is", SwingConstants.LEFT);
remarksL = new JLabel("remarks is", SwingConstants.LEFT);
studentnameTF = new JTextField(10);
courseTF = new JTextField(10);
yearTF = new JTextField(10);
quizgradeTF = new JTextField(10);
attendancegradeTF= new JTextField(10);
projectgradeTF = new JTextField(10);
examgradeTF = new JTextField(10);
finalgradeTF = new JTextField(10);
finalgradeTF.setEditable(false);
equivalentgradeTF = new JTextField(10);
remarksTF = new JTextField(10);
CalculateB = new JButton("CALCULATE");
cbHandler = new CalculateButtonHandler();
CalculateB.addActionListener(cbHandler);
ExitB = new JButton("Exit");
ebHandler = new ExitButtonHandler();
ExitB.addActionListener(ebHandler);
Container pane = getContentPane();
pane.setLayout(new GridLayout(15, 2));
pane.add(studentnameL);
pane.add(studentnameTF);
pane.add(courseL);
pane.add(courseTF);
pane.add(yearL);
pane.add(yearTF);
pane.add(quizgradeL);
pane.add(quizgradeTF);
pane.add(attendancegradeL);
pane.add(attendancegradeTF);
pane.add(projectgradeL);
pane.add(projectgradeTF);
pane.add(examgradeL);
pane.add(examgradeTF);
pane.add(finalgradeL);
pane.add(finalgradeTF);
pane.add(equivalentgradeL);
pane.add(equivalentgradeTF);
pane.add(remarksL);
pane.add(remarksTF);
pane.add(CalculateB);
pane.add(ExitB);
setSize(width, height);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
private class CalculateButtonHandler implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
String studentname, course, remarks;
double quizgrade, attendancegrade, projectgrade, examgrade, finalgrade, equivalentgrade;
quizgrade = Double.parseDouble(quizgradeTF.getText());
attendancegrade = Double.parseDouble(attendancegradeTF.getText());
projectgrade = Double.parseDouble(projectgradeTF.getText());
examgrade = Double.parseDouble(examgradeTF.getText());
quizgrade = quizgrade * .10;
attendancegrade = attendancegrade* .10;
projectgrade = projectgrade * .30;
examgrade = examgrade * .60;
finalgrade = (quizgrade + attendancegrade + projectgrade + examgrade) / 4;
finalgradeTF.setText("" + finalgrade);
equivalentgrade = Double.parseDouble(equivalentgradeTF.getText());
if (finalgrade >= 98)
equivalentgrade = 1.0;
else if (finalgrade >= 95)
equivalentgrade = 1.25;
else if (finalgrade >= 92)
equivalentgrade = 1.5;
else if (finalgrade >= 89)
equivalentgrade = 1.75;
else if (finalgrade >= 86)
equivalentgrade = 2.0;
else if (finalgrade >= 83)
equivalentgrade = 2.25;
else if (finalgrade >= 80)
equivalentgrade = 2.5;
else if (finalgrade >= 77)
equivalentgrade = 2.75;
else if (finalgrade >= 75)
equivalentgrade = 3.0;
finalgradeTF.setText("" + finalgrade);
}
}
private class ExitButtonHandler implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
System.exit(0);
}
}
public static void main(String[] args)
{
StudentPerformance rect = new StudentPerformance();
}
}