Calculation score Algorithm

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.