Package J;
Import Java.awt.Frame;
Import Java.awt.event.MouseAdapter;
Import java.awt.event.MouseEvent;
Import Java.awt.event.WindowAdapter;
Import java.awt.event.WindowEvent;
Import Javax.swing.Icon;
Import Javax.swing.ImageIcon;
Import Javax.swing.JButton;
Import Javax.swing.JLabel;
Import Javax.swing.JOptionPane;
Import Javax.swing.JTextField;
public class J {
public static void Main (string[] args)
{
Frame f=new frame ();
F.setlayout (null);//Free layout
F.settitle ("score Determination");//Set Caption
F.setsize (586, 540);//Sizing
F.setlocation (100, 100);//Set window position
JLabel l1=new JLabel ("results");
L1.setbounds (200, 150, 50, 50);
F.add (L1);
JTextField t=new JTextField ("Please enter results");
T.setbounds (300, 160, 100, 30);
F.add (t);
JButton b1=new JButton ("OK");
JButton b2=new JButton ("Cancel");
B1.setbounds (200,230,80,30);
F.add (B1);
B2.setbounds (320,230,80,30);
F.add (B2);
T.addmouselistener (New Mouseadapter () {
public void mouseclicked (MouseEvent e) {
T.settext ("");}
});
B1.addmouselistener (New Mouseadapter () {
public void mouseclicked (MouseEvent e)
{
String s;
S=t.gettext ();
Try
{
int a = 0;
A= Integer.parseint (s);
if (a<60&&a>=0)
{
Joptionpane.showmessagedialog (NULL, "failed");
}
else if (a<70&&a>=0)
{
Joptionpane.showmessagedialog (NULL, "Pass");
}
else if (a<80&&a>=0)
{
Joptionpane.showmessagedialog (NULL, "medium");
}
else if (a<90&&a>=0)
{
Joptionpane.showmessagedialog (NULL, "benign");
}
else if (a<=100&&a>=0)
{
Joptionpane.showmessagedialog (NULL, "excellent");
}
Else
{
Joptionpane.showmessagedialog (NULL, "input error");
}
}
catch (NumberFormatException E1)
{
Joptionpane.showmessagedialog (NULL, "input error");
}
}
});
B2.addmouselistener (New Mouseadapter () {
public void mouseclicked (MouseEvent e)
{
System.exit (0);
}
});
F.addwindowlistener
(
New Windowadapter () {
public void windowclosing (WindowEvent e) {
System.exit (0);
}
}
);
Icon i1 = new ImageIcon ("2.jpg");
JLabel bg=new JLabel (i1);
Bg.setbounds (0,0, 586,540);
F.add (BG);
F.setvisible (TRUE);//Display window
}
}
Calculation score Algorithm