import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.ImageIcon;
import javax.swing.JPanel;

import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.Font;
import java.awt.Color;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class assignment extends JFrame implements ActionListener
{
	JTextField T1,T2,T3,T4,T5,T6;
	public assignment()
	{
		JLabel L3=new JLabel("QUIZEES");
		JLabel L4=new JLabel("MIDTERM");
		JLabel L5=new JLabel("ASSIGNMENT");
		JLabel L6=new JLabel("FINAL");
		JButton b3=new JButton(" THE LAST TOTAL");
		add(L3,BorderLayout.WEST);
		add(L4,BorderLayout.WEST);
		add(L5,BorderLayout.WEST);
		add(L6,BorderLayout.WEST);
		add(b3,BorderLayout.EAST);
			b3.setBackground(Color.PINK);
		ImageIcon pic =new ImageIcon("ovp64illus.jpg");
	JLabel L2 =new JLabel(pic);
		add(L2,BorderLayout.CENTER);
	JPanel p=new JPanel();
	add(p,BorderLayout.CENTER);

		GridLayout g1=new GridLayout(3,3);
			p.setLayout(g1);
			
		JButton b1=new JButton("Result");
         add(b1,BorderLayout.EAST);
	b1.setBackground(Color.PINK);

		JButton b2=new JButton("EXIT");
			add(b2,BorderLayout.SOUTH);
				b2.setBackground(Color.RED);

		T1=new JTextField(10);
		T2=new JTextField(10);
		T3=new JTextField(10);
		T4=new JTextField(10);
		T5=new JTextField(10);
		T6=new JTextField(10);
	
		Font a=new Font("Arial",Font.BOLD,22);
		b1.setFont(a);
		b2.setFont(a);
	add(T1,BorderLayout.EAST);
		
	
		
		add(T2,BorderLayout.EAST);
	add(T3,BorderLayout.WEST);
		add(T4,BorderLayout.WEST);
	add(T5,BorderLayout.WEST);
		add(T6,BorderLayout.WEST);
			b2.addActionListener(this);
		b3.addActionListener(this);
	
		setDefaultCloseOperation(assignment.EXIT_ON_CLOSE);
	}
	public void actionPerformed(ActionEvent ae)
	{
		 double QUIZEES = Double.parseDouble(T3.getText());
    double MIDTERM = Double.parseDouble(T4.getText());
    double ASSIGNMENT = Double.parseDouble(T5.getText());
    double  FINAL = Double.parseDouble(T6.getText()); 
    Double  TOTAL = QUIZEES+ MIDTERM+ASSIGNMENT+FINAL;
    T2.setText(String.valueOf(TOTAL));
		String a=ae.getActionCommand();
		if(a.equals("Result"))
		{
			double m=Double.parseDouble(T1.getText());
			String P="PASS";
			String F="FAIL";
			if(m>60)
				T2.setText(P);
			else
				T2.setText(F);	
		}
		else
			System.exit(0);
	}
	public static void main(String[] args)
	{
		assignment F=new assignment();
		F.setVisible(true);
	}
}
