Pesquisar na Comunidade
Mostrando resultados para as tags ''ilegal''.
Encontrado 1 registro
-
Estou trabalhando em um código para fazer media de notas e para, se faltar um valor, dizer o mínimo que o aluno deveria tirar para passar. Quando percebi, apareceu esses erros, como: "ilegal start of type" -> if (notinha == 3) { "could not find symbol (variável nn, n1 e n2)" -> nn = 21 - (n1+n2+n3+n4); entre outros, alguém pode me ajudar? package calc; /** * * @author pedro */ public class maincalc extends javax.swing.JFrame { /** * Creates new form maincalc */ public maincalc() { initComponents(); } /** * 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"> private void initComponents() { jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); txtN1 = new javax.swing.JTextField(); txtN2 = new javax.swing.JTextField(); txtN3 = new javax.swing.JTextField(); txtN4 = new javax.swing.JTextField(); jButton1 = new javax.swing.JButton(); jLabel5 = new javax.swing.JLabel(); lblNota = new javax.swing.JLabel(); jLabel7 = new javax.swing.JLabel(); lblResult = new javax.swing.JLabel(); jLabel6 = new javax.swing.JLabel(); jLabel8 = new javax.swing.JLabel(); jLabel9 = new javax.swing.JLabel(); lblNn = new javax.swing.JLabel(); txtNotinhas = new javax.swing.JTextField(); jLabel10 = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jLabel1.setText("Primeira Nota"); jLabel2.setText("Segunda Nota"); jLabel3.setText("Terceira Nota"); jLabel4.setText("Quarta Nota"); txtN1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { txtN1ActionPerformed(evt); } }); jButton1.setText("Calcular"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); jLabel5.setText("Nota Trimestral:"); lblNota.setText("0"); jLabel7.setText("Resultado:"); lblResult.setText("N/A"); jLabel6.setFont(new java.awt.Font("Times New Roman", 1, 24)); // NOI18N jLabel6.setText("CMT"); jLabel8.setText("Criado por Pedro Luiz Ferreira de Oliveira"); lblNn.setText("N/A"); jLabel10.setText("Nº Notas"); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(layout.createSequentialGroup() .addGap(98, 98, 98) .addComponent(jButton1) .addGap(0, 0, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() .addGap(111, 111, 111) .addComponent(jLabel6) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel9))) .addGap(49, 49, 49)) .addGroup(layout.createSequentialGroup() .addGap(35, 35, 35) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jLabel3) .addComponent(jLabel2) .addComponent(jLabel1) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel5) .addComponent(jLabel7)) .addComponent(jLabel4)) .addGap(50, 50, 50) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(txtN3, javax.swing.GroupLayout.Alignment.LEADING) .addComponent(txtN2, javax.swing.GroupLayout.Alignment.LEADING) .addComponent(txtN4, javax.swing.GroupLayout.Alignment.LEADING) .addComponent(txtN1, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(lblNota) .addComponent(lblResult)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 38, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addComponent(jLabel10) .addGap(18, 18, 18) .addComponent(txtNotinhas, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(lblNn, javax.swing.GroupLayout.Alignment.TRAILING))) .addGroup(layout.createSequentialGroup() .addComponent(jLabel8) .addGap(0, 0, Short.MAX_VALUE))) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel6) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel9) .addGap(24, 24, 24) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jLabel1) .addComponent(txtN1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addComponent(jLabel2)) .addComponent(txtN2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addComponent(jLabel3)) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(txtN3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(txtNotinhas, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel10)))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(txtN4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel4) .addComponent(lblNn)) .addGap(18, 18, 18) .addComponent(jButton1) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jLabel5) .addGap(18, 18, 18) .addComponent(jLabel7) .addGap(21, 21, 21) .addComponent(jLabel8)) .addGroup(layout.createSequentialGroup() .addComponent(lblNota) .addGap(18, 18, 18) .addComponent(lblResult)))) ); pack(); }// </editor-fold> private static final String EMPTY_STRING = ""; private void txtN1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { float n1 = Float.parseFloat(txtN1.getText()); float n2 = Float.parseFloat(txtN2.getText()); float n3 = Float.parseFloat(txtN3.getText()); float n4 = Float.parseFloat(txtN4.getText()); int notinha = Integer.parseInt(txtNotinhas.getText()); float nn = 0; int np; if (n4==0 || n3==0 || n2==0 || n1==0) { np = 3; } else { np = 4; } if (n3==0 && n4==0 || n4==0 && n2==0 || n4==0 && n1==0 || n3==0 && n2==0 || n3==0 && n1==0 || n2==0 && n1==0) { np = 2; } float nm = (n1+n2+n3+n4)/np; } if (notinha == 3) { nn = 21 - (n1+n2+n3+n4); lblNn.setText("Você precisa tirar " + nn); if (nn <= 0) { lblNn.setText("N/A"); } lblNota.setText(Float.toString(nm)); if (nm>=7) { lblResult.setText("Aprovado"); } else { lblResult.setText("Recuperação"); } }