package defaultPackage;

/*
	A basic extension of the java.applet.Applet class
 */

import java.awt.*;
import java.applet.*;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.lang.Double;
import java.lang.String;

public class Applet1 extends Applet
{
    public boolean ok1=false;
    public boolean ok2=false;
    public boolean ok3=false;
    public boolean ok4=false;
    public boolean ok5=false;
    public boolean ok6=false;
    public boolean ok7=false;
    public boolean ok8=false;
    public boolean ok9=false;
    public boolean ok10=false;
    public boolean ok11=false;
    public Double cash;
    public Double accRec;
    public Double inv;
    public Double fixass;
    public Double accPay;
    public Double ltd;
    public Double stock;
    public Double retear;
    public Double sales;
    public Double cgs;
    public Double gcaexp;
    public Double V1;
    public Double V2;
    public Double V3;
    public Double V4;
    public Double V5;
    public Double V6;
    
	public void init()
	{
		// Take out this line if you don't use symantec.itools.net.RelativeURL or symantec.itools.awt.util.StatusScroller
		//symantec.itools.lang.Context.setApplet(this);
	
		// This code is automatically generated by Visual Cafe when you add
		// components to the visual environment. It instantiates and initializes
		// the components. To modify the code, only use code syntax that matches
		// what Visual Cafe can generate, or Visual Cafe may be unable to back
		// parse your Java file into its visual environment.
		//{{INIT_CONTROLS
		setLayout(null);
		setBackground(java.awt.Color.lightGray);
		setSize(690,345);
		JLabel1.setText("Bankroto spejimas");
		add(JLabel1);
		JLabel1.setFont(new Font("Dialog", Font.BOLD, 18));
		JLabel1.setBounds(224,12,180,36);
		JLabel2.setText("Pinigai ir lygiareiksmiai");
		add(JLabel2);
		JLabel2.setBounds(24,72,150,24);
		JTextField1.setText("0");
		add(JTextField1);
		JTextField1.setBackground(java.awt.Color.white);
		JTextField1.setBounds(180,72,100,24);
		JTextField2.setText("0");
		add(JTextField2);
		JTextField2.setBounds(180,96,100,24);
		JLabel3.setText("Pajamu saskaitos");
		add(JLabel3);
		JLabel3.setBounds(24,96,132,24);
		JTextField3.setText("0");
		add(JTextField3);
		JTextField3.setBounds(180,120,100,24);
		JLabel4.setText("Inventorius");
		add(JLabel4);
		JLabel4.setBounds(24,120,132,24);
		JLabel5.setText("Fiksuotas turtas");
		add(JLabel5);
		JLabel5.setBounds(24,144,132,24);
		JTextField4.setText("0");
		add(JTextField4);
		JTextField4.setBounds(180,144,100,24);
		JTextField5.setText("0");
		add(JTextField5);
		JTextField5.setBounds(300,72,100,24);
		JTextField6.setText("0");
		add(JTextField6);
		JTextField6.setBounds(300,96,100,24);
		JLabel6.setText("Mokejimo saskaitos");
		add(JLabel6);
		JLabel6.setBounds(408,72,132,24);
		JLabel7.setText("Ilgalaikis isiskolinimas");
		add(JLabel7);
		JLabel7.setBounds(408,96,160,24);
		JLabel8.setText("Bendras Inventorius");
		add(JLabel8);
		JLabel8.setBounds(408,120,132,24);
		JLabel9.setText("Nepaskirstytas pelnas");
		add(JLabel9);
		JLabel9.setBounds(408,144,160,24);
		JTextField7.setText("0");
		add(JTextField7);
		JTextField7.setBounds(300,120,100,24);
		JTextField8.setText("0");
		add(JTextField8);
		JTextField8.setBounds(300,144,100,24);
		JLabel10.setText("Pardavimai");
		add(JLabel10);
		JLabel10.setBounds(24,204,132,24);
		JLabel11.setText("Parduotu prekiu kainos");
		add(JLabel11);
		JLabel11.setBounds(24,228,180,24);
		JTextField9.setText("0");
		add(JTextField9);
		JTextField9.setBounds(180,204,100,24);
		JTextField10.setText("0");
		add(JTextField10);
		JTextField10.setBounds(180,228,100,24);
		JLabel12.setText("Parduotu prekiu islaidos");
		add(JLabel12);
		JLabel12.setBounds(24,252,180,24);
		JTextField11.setText("0");
		add(JTextField11);
		JTextField11.setBounds(180,252,100,24);
		JLabel13.setText("TURTAS = APMOKESTINIMAS");
		add(JLabel13);
		JLabel13.setForeground(new java.awt.Color(102,102,153));
		JLabel13.setFont(new Font("Dialog", Font.BOLD, 14));
		JLabel13.setBounds(224,48,230,28);
		JLabel15.setText("Daliniu pajamu ataskaita");
		add(JLabel15);
		JLabel15.setForeground(new java.awt.Color(102,102,153));
		JLabel15.setFont(new Font("Dialog", Font.BOLD, 14));
		JLabel15.setBounds(24,180,230,28);

		JLabel16.setText("(Altman) Bankroto tikimybe:");
		add(JLabel16);
		JLabel16.setForeground(new java.awt.Color(102,102,153));
		JLabel16.setBounds(294,204,180,26);

		JLabel17.setText("(Springate) Bankroto tikimybe:");
		add(JLabel17);
		JLabel17.setForeground(new java.awt.Color(102,102,153));
		JLabel17.setBounds(294,234,200,26);

		JLabel18.setText("(Fulmer) Bankroto tikimybe:");
		add(JLabel18);
		JLabel18.setForeground(new java.awt.Color(102,102,153));
		JLabel18.setBounds(294,264,200,26);

		JButton1.setText("Skaiciuoti");
		add(JButton1);
		JButton1.setBackground(new java.awt.Color(228,228,228));
		JButton1.setForeground(new java.awt.Color(255,050,050));
		JButton1.setBounds(300,305,120,28);

		JTextField12.setSelectionColor(new java.awt.Color(228,228,228));
		JTextField12.setEditable(false);
		add(JTextField12);
		JTextField12.setBounds(500,204,180,22);

		JTextField13.setSelectionColor(new java.awt.Color(228,228,228));
		JTextField13.setEditable(false);
		add(JTextField13);
		JTextField13.setBounds(500,234,180,22); // 396 - stulpelis ; 230 - eilute; 150 - ilgis ; 22 - aukstis.

		JTextField14.setSelectionColor(new java.awt.Color(228,228,228));
		JTextField14.setEditable(false);
		add(JTextField14);
		JTextField14.setBounds(500,264,180,22); // 396 - stulpelis ; 230 - eilute; 150 - ilgis ; 22 - aukstis.

		
		//}}
	
		//{{REGISTER_LISTENERS
		//SymMouse aSymMouse = new SymMouse();
		//JButton1.addMouseListener(aSymMouse);
		SymAction lSymAction = new SymAction();
		JButton1.addActionListener(lSymAction);
		SymFocus aSymFocus = new SymFocus();
		JTextField1.addFocusListener(aSymFocus);
		JTextField5.addFocusListener(aSymFocus);
		JTextField2.addFocusListener(aSymFocus);
		JTextField6.addFocusListener(aSymFocus);
		JTextField3.addFocusListener(aSymFocus);
		JTextField7.addFocusListener(aSymFocus);
		JTextField4.addFocusListener(aSymFocus);
		JTextField8.addFocusListener(aSymFocus);
		JTextField9.addFocusListener(aSymFocus);
		JTextField10.addFocusListener(aSymFocus);
		JTextField11.addFocusListener(aSymFocus);
		//}}
	}
	
	//{{DECLARE_CONTROLS
	javax.swing.JLabel JLabel1 = new javax.swing.JLabel();
	javax.swing.JLabel JLabel2 = new javax.swing.JLabel();
	javax.swing.JTextField JTextField1 = new javax.swing.JTextField();
	javax.swing.JTextField JTextField2 = new javax.swing.JTextField();
	javax.swing.JLabel JLabel3 = new javax.swing.JLabel();
	javax.swing.JTextField JTextField3 = new javax.swing.JTextField();
	javax.swing.JLabel JLabel4 = new javax.swing.JLabel();
	javax.swing.JLabel JLabel5 = new javax.swing.JLabel();
	javax.swing.JTextField JTextField4 = new javax.swing.JTextField();
	javax.swing.JTextField JTextField5 = new javax.swing.JTextField();
	javax.swing.JTextField JTextField6 = new javax.swing.JTextField();
	javax.swing.JLabel JLabel6 = new javax.swing.JLabel();
	javax.swing.JLabel JLabel7 = new javax.swing.JLabel();
	javax.swing.JLabel JLabel8 = new javax.swing.JLabel();
	javax.swing.JLabel JLabel9 = new javax.swing.JLabel();
	javax.swing.JTextField JTextField7 = new javax.swing.JTextField();
	javax.swing.JTextField JTextField8 = new javax.swing.JTextField();
	javax.swing.JLabel JLabel10 = new javax.swing.JLabel();
	javax.swing.JLabel JLabel11 = new javax.swing.JLabel();
	javax.swing.JTextField JTextField9 = new javax.swing.JTextField();
	javax.swing.JTextField JTextField10 = new javax.swing.JTextField();
	javax.swing.JLabel JLabel12 = new javax.swing.JLabel();
	javax.swing.JTextField JTextField11 = new javax.swing.JTextField();
	javax.swing.JLabel JLabel13 = new javax.swing.JLabel();
	javax.swing.JLabel JLabel15 = new javax.swing.JLabel();
	javax.swing.JLabel JLabel16 = new javax.swing.JLabel();
	javax.swing.JLabel JLabel17 = new javax.swing.JLabel();
	javax.swing.JLabel JLabel18 = new javax.swing.JLabel();
	javax.swing.JButton JButton1 = new javax.swing.JButton();
	javax.swing.JTextField JTextField12 = new javax.swing.JTextField();
	javax.swing.JTextField JTextField13 = new javax.swing.JTextField();
	javax.swing.JTextField JTextField14 = new javax.swing.JTextField();
	//}}

	/*class SymMouse extends java.awt.event.MouseAdapter
	{
		public void mouseClicked(java.awt.event.MouseEvent event)
		{
			Object object = event.getSource();
			if (object == JButton1)
				JButton1_mouseClicked(event);
		}
	}

	void JButton1_mouseClicked(java.awt.event.MouseEvent event)
	{
		// to do: code goes here.
		
			 
	}*/

	class SymAction implements java.awt.event.ActionListener
	{
		public void actionPerformed(java.awt.event.ActionEvent event)
		{
			Object object = event.getSource();
			if (object == JButton1)
				JButton1_actionPerformed(event);
		}
	}

	void JButton1_actionPerformed(java.awt.event.ActionEvent event)
	{
		// to do: code goes here.
		if (ok1 & ok2 & ok3 & ok4 & ok5 & ok6 & ok7 & ok7 & ok8 & ok9 & ok10 & ok11)
		    {
		    JTextField1.setBackground(new Color(255,255,255));
		    JTextField2.setBackground(new Color(255,255,255));
		    JTextField3.setBackground(new Color(255,255,255));
		    JTextField4.setBackground(new Color(255,255,255));
		    JTextField5.setBackground(new Color(255,255,255));
		    JTextField6.setBackground(new Color(255,255,255));
		    JTextField7.setBackground(new Color(255,255,255));
		    JTextField8.setBackground(new Color(255,255,255));
		    JTextField9.setBackground(new Color(255,255,255));
		    JTextField10.setBackground(new Color(255,255,255));
		    JTextField11.setBackground(new Color(255,255,255));
		    
	    double konst= 0.239;
            Double cash = Double.valueOf(JTextField1.getText());
            Double accRec = Double.valueOf(JTextField2.getText());
            Double inv = Double.valueOf(JTextField3.getText());
            Double fixass = Double.valueOf(JTextField4.getText());
            Double accPay = Double.valueOf(JTextField5.getText());
            Double ltd = Double.valueOf(JTextField6.getText());
            Double stock = Double.valueOf(JTextField7.getText());
            Double retear = Double.valueOf(JTextField8.getText());
            Double sales = Double.valueOf(JTextField9.getText());
            Double cgs = Double.valueOf(JTextField10.getText());
            Double gcaexp = Double.valueOf(JTextField11.getText());
            double tass = cash.doubleValue()+accRec.doubleValue()+inv.doubleValue()+fixass.doubleValue();
            double inc = sales.doubleValue()-cgs.doubleValue()-gcaexp.doubleValue();

/*
            double V1 = fixass.doubleValue()/stock.doubleValue(); //– nepaskirstytasis pelnas/visas turtas
            double V2 = sales.doubleValue()/stock.doubleValue(); //– pardavimai/visas turtas
            double V3 = ; //– EBT/paprastosios akcijos
            double V4 = cash.doubleValue(); //– pinigu srautai
            double V5 = /stock.doubleValue(); //– skolos/visas turtas
            double V6 = /stock.doubleValue(); //– dabartines skolos/visas turtas
            double V7 = ltd.doubleValue()/stock.doubleValue(); //– ilgalaikiai aktyvai/visas turtas
            double V8 = /tass.doubleValue(); //– apyvartines lešos/visos skolos
            double V9 = ; //– XXXX LogEBIT/palukanos
*/
            if (tass == 0)
            {
                JTextField1.setBackground(new Color(255,155,155));
                JTextField2.setBackground(new Color(255,155,155));
                JTextField3.setBackground(new Color(255,155,155));
                JTextField4.setBackground(new Color(255,155,155));
                JTextField12.setText("Patikrinkite ivestas reiksmes");
                JTextField13.setText("Patikrinkite ivestas reiksmes");
                JTextField14.setText("Patikrinkite ivestas reiksmes");
            }
            else {
                if ((accPay.doubleValue()+ltd.doubleValue()) == 0)
                {
                    JTextField5.setBackground(new Color(255,155,155));
                    JTextField6.setBackground(new Color(255,155,155));
                    JTextField12.setText("Patikrinkite ivestas reiksmes");
                    JTextField13.setText("Patikrinkite ivestas reiksmes");
                    JTextField14.setText("Patikrinkite ivestas reiksmes");
                }
                else {
                    if ((tass - accPay.doubleValue()) == 0)
                    {
                        JTextField1.setBackground(new Color(255,155,155));
                        JTextField2.setBackground(new Color(255,155,155));
                        JTextField3.setBackground(new Color(255,155,155));
                        JTextField4.setBackground(new Color(255,155,155));
                        JTextField5.setBackground(new Color(255,155,155));
                        JTextField12.setText("Patikrinkite ivestas reiksmes");
                        JTextField13.setText("Patikrinkite ivestas reiksmes");
                        JTextField14.setText("Patikrinkite ivestas reiksmes");
                    }
                    else
                    if (tass != (accPay.doubleValue()+ltd.doubleValue()+stock.doubleValue()+
                    retear.doubleValue()))
                    {
                        JTextField1.setBackground(new Color(255,155,155));
                        JTextField2.setBackground(new Color(255,155,155));
                        JTextField3.setBackground(new Color(255,155,155));
                        JTextField4.setBackground(new Color(255,155,155));
                        JTextField5.setBackground(new Color(255,155,155));
                        JTextField6.setBackground(new Color(255,155,155));
                        JTextField7.setBackground(new Color(255,155,155));
                        JTextField8.setBackground(new Color(255,155,155));
                        JTextField12.setText("Patikrinkite ivestas reiksmes");
                        JTextField13.setText("Patikrinkite ivestas reiksmes");
                        JTextField14.setText("Patikrinkite ivestas reiksmes");
                    }
                    else
//Skaiciuojame pagal Springate metoda
                    {
                    double y= 1.03*(cash.doubleValue()/tass)+
			3.07*(((sales.doubleValue()*cgs.doubleValue())-(sales.doubleValue()*gcaexp.doubleValue()))/tass) + 0.66*(((sales.doubleValue()*cgs.doubleValue())-(sales.doubleValue()*gcaexp.doubleValue()))/accPay.doubleValue()) + 0.4*(sales.doubleValue()/tass);
    //JTextField12.setText(java.lang.Double.toString(1/(1+java.lang.Math.exp(y*0.862))));
                        JTextField13.setText(java.lang.Double.toString(1/(1+java.lang.Math.exp(y*0.862)))); //          

// senas metodas

			y= inv.doubleValue()/sales.doubleValue()*(-0.108)-
                        1.583*accRec.doubleValue()/inv.doubleValue()-
                        10.78*cash.doubleValue()/tass+
                        (accRec.doubleValue()+cash.doubleValue())/(accPay.doubleValue()+ltd.doubleValue())*3.074+
                        inc/(tass-accPay.doubleValue())*0.486-
                        4.35*ltd.doubleValue()/(tass-accPay.doubleValue())+
                        0.11*sales.doubleValue()/fixass.doubleValue();
                        JTextField14.setText(java.lang.Double.toString(1/(1+java.lang.Math.exp(y*0.23883))));


//Altmano metodas

//working capital - cash.doubleValue()
//total assets - tass
//net profit before interest and taxes - (sales * cgs) - (sales * gcaexp)
//net profit before taxes - (sales * cgs) - (sales * gcaexp)
//current liabilities - accpay
//sales - sales.doubleValue()
			Double A=cash.doubleValue()/tass;
			Double B=retear.doubleValue()/tass;
			Double C=(sales.doubleValue() * cgs.doubleValue() - sales.doubleValue() * gcaexp.doubleValue()) / tass;
			Double D=(accPay.doubleValue() + stock.doubleValue()) / ltd.doubleValue();
			Double E=sales.doubleValue() / tass;
			y=1.2*A + 1.4*B + 3.3*C + 0.6*D + 0.999*E;
			JTextField12.setText(java.lang.Double.toString(1/(1+java.lang.Math.exp(y*2.675))));

                    }
                }
            }
		    }
		    else
		    {
		        JTextField1.requestFocus();
		        JTextField2.requestFocus();
		        JTextField3.requestFocus();
		        JTextField4.requestFocus();
		        JTextField5.requestFocus();
		        JTextField6.requestFocus();
		        JTextField7.requestFocus();
		        JTextField8.requestFocus();
		        JTextField9.requestFocus();
		        JTextField10.requestFocus();
		        JTextField11.requestFocus();
		        JTextField12.setText("Ziurekite i raudonas reiksmes");	
		        JTextField13.setText("Ziurekite i raudonas reiksmes");		        
    	    }
	}

	class SymFocus extends java.awt.event.FocusAdapter
	{
		public void focusLost(java.awt.event.FocusEvent event)
		{
			Object object = event.getSource();
			if (object == JTextField1)
				JTextField1_focusLost(event);
			else if (object == JTextField5)
				JTextField5_focusLost(event);
			else if (object == JTextField2)
				JTextField2_focusLost(event);
			else if (object == JTextField6)
				JTextField6_focusLost(event);
			else if (object == JTextField3)
				JTextField3_focusLost(event);
			else if (object == JTextField7)
				JTextField7_focusLost(event);
			else if (object == JTextField4)
				JTextField4_focusLost(event);
			else if (object == JTextField8)
				JTextField8_focusLost(event);
			else if (object == JTextField9)
				JTextField9_focusLost(event);
			else if (object == JTextField10)
				JTextField10_focusLost(event);
			else if (object == JTextField11)
				JTextField11_focusLost(event);
		}
	}

	void JTextField1_focusLost(java.awt.event.FocusEvent event)
	{
		// to do: code goes here.
		try
        {
            JTextField1.setBackground(new Color(255, 255, 255));
            Double.valueOf(JTextField1.getText());
            ok1 = true;
        }
        catch(NumberFormatException exc)
        {
            JTextField1.setBackground(new Color(255, 155, 155));
            ok1 = false;
        }	 
	}

	void JTextField5_focusLost(java.awt.event.FocusEvent event)
	{
		// to do: code goes here.
		try
        {
            JTextField5.setBackground(new Color(255, 255, 255));
            Double.valueOf(JTextField5.getText());
            ok5 = true;
        }
        catch(NumberFormatException exc)
        {
            JTextField5.setBackground(new Color(255, 155, 155));
            ok5 = false;
        }	 
			 
	}

	void JTextField2_focusLost(java.awt.event.FocusEvent event)
	{
		// to do: code goes here.
		try
        {
            JTextField2.setBackground(new Color(255, 255, 255));
            Double.valueOf(JTextField2.getText());
            ok2 = true;
        }
        catch(NumberFormatException exc)
        {
            JTextField2.setBackground(new Color(255, 155, 155));
            ok2 = false;
        }	 
			 
	}

	void JTextField6_focusLost(java.awt.event.FocusEvent event)
	{
		// to do: code goes here.
        try
        {
            JTextField6.setBackground(new Color(255, 255, 255));
            Double.valueOf(JTextField6.getText());
            ok6 = true;
        }
        catch(NumberFormatException exc)
        {
            JTextField6.setBackground(new Color(255, 155, 155));
            ok6 = false;
        }	
	}

	void JTextField3_focusLost(java.awt.event.FocusEvent event)
	{
		// to do: code goes here.
		try
        {
            if (Double.valueOf(JTextField3.getText()).doubleValue()!= 0)
            {
                JTextField3.setBackground(new Color(255, 255, 255));
                ok3 = true;
            }
            else
            {
                JTextField3.setBackground(new Color(255, 155, 155));    
            }
        }
        catch(NumberFormatException exc)
        {
            JTextField3.setBackground(new Color(255, 155, 155));
            ok3 = false;
        }	 
	}

	void JTextField7_focusLost(java.awt.event.FocusEvent event)
	{
		// to do: code goes here.
		try
        {
            JTextField7.setBackground(new Color(255, 255, 255));
            Double.valueOf(JTextField7.getText());
            ok7 = true;
        }
        catch(NumberFormatException exc)
        {
            JTextField7.setBackground(new Color(255, 155, 155));
            ok7 = false;
        }	 
	}

	void JTextField4_focusLost(java.awt.event.FocusEvent event)
	{
		// to do: code goes here.
		try
        {
            if (Double.valueOf(JTextField4.getText()).doubleValue()!= 0)
            {
                JTextField4.setBackground(new Color(255, 255, 255));
                ok4 = true;
            }
            else
            {
                JTextField4.setBackground(new Color(255, 155, 155));    
            }
        }
        catch(NumberFormatException exc)
        {
            JTextField4.setBackground(new Color(255, 155, 155));
            ok4 = false;
        }	 
	}

	void JTextField8_focusLost(java.awt.event.FocusEvent event)
	{
		// to do: code goes here.
		try
        {
            JTextField8.setBackground(new Color(255, 255, 255));
            Double.valueOf(JTextField8.getText());
            ok8 = true;
        }
        catch(NumberFormatException exc)
        {
            JTextField8.setBackground(new Color(255, 155, 155));
            ok8 = false;
        }	 
	}

	void JTextField9_focusLost(java.awt.event.FocusEvent event)
	{
		// to do: code goes here.
		try
        {
            if (Double.valueOf(JTextField9.getText()).doubleValue()!= 0)
            {
                JTextField9.setBackground(new Color(255, 255, 255));
                ok9 = true;
            }
            else
            {
                JTextField9.setBackground(new Color(255, 155, 155));    
            }
         }
        catch(NumberFormatException exc)
        {
            JTextField9.setBackground(new Color(255, 155, 155));
            ok9 = false;
        }	 
	}

	void JTextField10_focusLost(java.awt.event.FocusEvent event)
	{
		// to do: code goes here.
		try
        {
            JTextField10.setBackground(new Color(255, 255, 255));
            Double.valueOf(JTextField10.getText());
            ok10 = true;
        }
        catch(NumberFormatException exc)
        {
            JTextField10.setBackground(new Color(255, 155, 155));
            ok10 = false;
        }	 
	}

	void JTextField11_focusLost(java.awt.event.FocusEvent event)
	{
		// to do: code goes here.
		try
        {
            JTextField11.setBackground(new Color(255, 255, 255));
            Double.valueOf(JTextField11.getText());
            ok11 = true;
        }
        catch(NumberFormatException exc)
        {
            JTextField11.setBackground(new Color(255, 155, 155));
            ok11 = false;
        }	 
	}
}
