/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package mat;

import java.awt.Dimension;
import java.awt.Toolkit;
import java.util.Scanner;

/**
 *
 * @author samuel
 */
public class tela2 extends javax.swing.JFrame {

    /**
     * Creates new form tela2
     */
    public tela2() {
        initComponents();
        q3.setVisible(true);
        q3.setEditable(false);
          centralizarComponente();
    }
    public void centralizarComponente() {
        Dimension ds = Toolkit.getDefaultToolkit().getScreenSize();
        Dimension dw = getSize();
        setLocation((ds.width - dw.width) / 2, (ds.height - dw.height) / 2);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        q2 = new javax.swing.JTextField();
        jButton2 = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();
        q3 = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        q1 = new javax.swing.JTextField();
        jButton6 = new javax.swing.JButton();
        jButton7 = new javax.swing.JButton();
        jLabel5 = new javax.swing.JLabel();
        jButton8 = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        getContentPane().setLayout(null);

        q2.setFont(new java.awt.Font("Noto Sans", 1, 14)); // NOI18N
        getContentPane().add(q2);
        q2.setBounds(764, 350, 91, 50);

        jButton2.setFont(new java.awt.Font("Noto Sans", 0, 18)); // NOI18N
        jButton2.setText("Menu");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton2);
        jButton2.setBounds(59, 675, 104, 40);

        jButton1.setFont(new java.awt.Font("Noto Sans", 1, 14)); // NOI18N
        jButton1.setText("Calcular");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton1);
        jButton1.setBounds(760, 480, 110, 44);

        q3.setFont(new java.awt.Font("Noto Sans", 1, 14)); // NOI18N
        getContentPane().add(q3);
        q3.setBounds(280, 480, 326, 47);

        jLabel1.setFont(new java.awt.Font("Century Schoolbook L", 1, 24)); // NOI18N
        jLabel1.setText("Digite a media de gols do time por jogo");
        getContentPane().add(jLabel1);
        jLabel1.setBounds(59, 336, 693, 48);

        jLabel3.setFont(new java.awt.Font("Century Schoolbook L", 1, 24)); // NOI18N
        jLabel3.setForeground(new java.awt.Color(233, 18, 18));
        jLabel3.setText("Probabilidade é:");
        getContentPane().add(jLabel3);
        jLabel3.setBounds(320, 430, 281, 47);

        jLabel2.setFont(new java.awt.Font("Century Schoolbook L", 1, 24)); // NOI18N
        jLabel2.setText("Digite quantidade de gols que devem ocorrer");
        getContentPane().add(jLabel2);
        jLabel2.setBounds(59, 223, 587, 52);

        q1.setFont(new java.awt.Font("Noto Sans", 1, 14)); // NOI18N
        q1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                q1ActionPerformed(evt);
            }
        });
        getContentPane().add(q1);
        q1.setBounds(764, 224, 91, 56);

        jButton6.setFont(new java.awt.Font("Noto Sans", 0, 18)); // NOI18N
        jButton6.setText("Sair");
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton6);
        jButton6.setBounds(830, 660, 104, 40);

        jButton7.setFont(new java.awt.Font("Noto Sans", 0, 18)); // NOI18N
        jButton7.setText("Ajuda");
        jButton7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton7ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton7);
        jButton7.setBounds(720, 660, 90, 40);

        jLabel5.setFont(new java.awt.Font("Century Schoolbook L", 0, 36)); // NOI18N
        jLabel5.setText("N(s) Pontos por Partida.");
        getContentPane().add(jLabel5);
        jLabel5.setBounds(300, 50, 661, 112);

        jButton8.setFont(new java.awt.Font("Noto Sans", 0, 18)); // NOI18N
        jButton8.setText("Voltar");
        jButton8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton8ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton8);
        jButton8.setBounds(600, 660, 104, 40);

        jLabel4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/IMAGEM/newpackage/ok.png"))); // NOI18N
        getContentPane().add(jLabel4);
        jLabel4.setBounds(0, -10, 1030, 790);

        setSize(new java.awt.Dimension(1028, 772));
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        MENU M = new MENU();
        this.setVisible(false);
        M.setVisible(true);

    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        //k quantidade desejada de ocorrencias
        // λ numero de eventos que ocorre em determinado periodo de tempo
        // e = 2,718 281 828 459 045 235 360 287.
        Scanner dado = new Scanner(System.in);

        double f = 0;
        //double y = 0;
        //int k = 0;
        double € = 2.718281828459045235360287;
        int k1 = 1;
        //System.out.println("digite quantidade de gols que devem ocorrer");
        int k = Integer.parseInt(q1.getText());
        //k = dado.nextInt();
        //System.out.println("digite a media de gols do time por jogo");
        double y = Double.parseDouble(q2.getText());
        //y = dado.nextDouble();

        for (int x = k; x >= 1; x--) {
            k1 = k1 * x;
        }

        f = ((Math.pow(€, -y)) * (Math.pow(y, k))) / k1;

        //System.out.println("Probabilidade de marcar "+ k+ " em uma partida é: "+ f);
        q3.setVisible(true);
        q3.setText(String.valueOf(f*100 +" %"));

    }//GEN-LAST:event_jButton1ActionPerformed

    private void q1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_q1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_q1ActionPerformed

    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
        System.exit(0);
    }//GEN-LAST:event_jButton6ActionPerformed

    private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
        ajuda05 T = new ajuda05();
        this.setVisible(false);
        T.setVisible(true);
    }//GEN-LAST:event_jButton7ActionPerformed

    private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed
         MENU M = new MENU();
       this.setVisible(false);
       M.setVisible(true);
    }//GEN-LAST:event_jButton8ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(tela2.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(tela2.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(tela2.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(tela2.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new tela2().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JButton jButton8;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JTextField q1;
    private javax.swing.JTextField q2;
    private javax.swing.JTextField q3;
    // End of variables declaration//GEN-END:variables
}
