





























Studia grazie alle numerose risorse presenti su Docsity
Guadagna punti aiutando altri studenti oppure acquistali con un piano Premium
Prepara i tuoi esami
Studia grazie alle numerose risorse presenti su Docsity
Prepara i tuoi esami con i documenti condivisi da studenti come te su Docsity
Trova i documenti specifici per gli esami della tua università
Preparati con lezioni e prove svolte basate sui programmi universitari!
Rispondi a reali domande d’esame e scopri la tua preparazione
Riassumi i tuoi documenti, fagli domande, convertili in quiz e mappe concettuali
Studia con prove svolte, tesine e consigli utili
Togliti ogni dubbio leggendo le risposte alle domande fatte da altri studenti come te
Esplora i documenti più scaricati per gli argomenti di studio più popolari
Ottieni i punti per scaricare
Guadagna punti aiutando altri studenti oppure acquistali con un piano Premium
Calcolatrice (codice in java) con componente grafico, java
Tipologia: Esercizi
1 / 37
Questa pagina non è visibile nell’anteprima
Non perderti parti importanti!






























jButton8.setText("8"); jButton8.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton8ActionPerformed(evt); } }); jButton5.setText("5"); jButton5.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton5ActionPerformed(evt); } }); jButton6.setText("6"); jButton6.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton6ActionPerformed(evt); } }); jButton7.setText("7"); jButton7.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton7ActionPerformed(evt); } }); jButton9.setText("9"); jButton9.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton9ActionPerformed(evt); } }); jButton0.setText("0"); jButton0.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton0ActionPerformed(evt); } }); jButtonSomma.setText("+"); jButtonSomma.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonSommaActionPerformed(evt);
jButtonUguale.setText("="); jButtonUguale.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonUgualeActionPerformed(evt); } }); jButtonMoltiplicazione.setText("*"); jButtonMoltiplicazione.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonMoltiplicazioneActionPerformed(evt); } }); jButtonDivisione.setText("/"); jButtonDivisione.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonDivisioneActionPerformed(evt); } }); jButtonSottrazione.setText("-"); jButtonSottrazione.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonSottrazioneActionPerformed(evt); } }); jButtonVirgola.setText(","); jButtonVirgola.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonVirgolaActionPerformed(evt); } }); jButtonCancella.setText("C"); jButtonCancella.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonCancellaActionPerformed(evt); } }); jLabel2.setFont(new java.awt.Font("Times New Roman", 0, 18)); // NOI18N jLabel2.setText("Calcolatrice");
jButtonElevamentoN.setText("X^N"); jButtonElevamentoN.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonElevamentoNActionPerformed(evt); } }); jButtonReciproco.setText("1/N"); jButtonReciproco.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonReciprocoActionPerformed(evt); } }); jButtonFattoriale.setText("Fattoriale"); jButtonFattoriale.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonFattorialeActionPerformed(evt); } }); jButtonMem.setText("MEM"); jButtonMem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonMemActionPerformed(evt); } }); jButtonM.setText("M+"); jButtonM.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonMActionPerformed(evt); } }); jButtonSto.setText("STO"); jButtonSto.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonStoActionPerformed(evt); } }); jLabelErrore.setForeground(new java.awt.Color(255, 51, 51)); jLabelErrore.setText("Errore di sintassi"); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jTextField1) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButton4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton2)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jButton3) .addComponent(jButton6)) .addGap(11, 11, 11) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jButtonMoltiplicazione, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButtonMem, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButtonUguale, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGap(2, 12, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jButton7) .addGap(18, 18, 18) .addComponent(jButton8) .addGap(18, 18, 18) .addComponent(jButton9) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jButtonDivisione) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButtonM, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addComponent(jButton0, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(jButtonVirgola, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButtonSomma) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButtonCancella, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGap(0, 0, Short.MAX_VALUE)))) .addGroup(layout.createSequentialGroup() .addGap(43, 43, 43) .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(73, 73, 73) .addComponent(jLabelErrore, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(19, 19, 19) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel2) .addComponent(jLabelErrore)) .addGap(18, 18, 18) .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(38, 38, 38) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButton7) .addComponent(jButton8) .addComponent(jButton9) .addComponent(jButtonDivisione) .addComponent(jButtonM)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButton4) .addComponent(jButton5) .addComponent(jButtonMoltiplicazione) .addComponent(jButtonMem)) .addComponent(jButton6)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButtonSottrazione) .addComponent(jButton3) .addComponent(jButton2) .addComponent(jButton1) .addComponent(jButtonSto)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButtonVirgola) .addComponent(jButtonSomma) .addComponent(jButton0) .addComponent(jButtonCancella)) .addGap(27, 27, 27)
}//GEN-LAST:event_jButton2ActionPerformed private void jButtonSommaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSommaActionPerformed boolean isErrore; contatoreOP++; jTextField1.setText(v.SchermoOp("")); isErrore=v.Errori(contatoreOP); if(isErrore){ jLabelErrore.setVisible(true); contatoreOP--; }else{ v.Somma(jTextField1.getText()); } }//GEN-LAST:event_jButtonSommaActionPerformed private void jButtonUgualeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonUgualeActionPerformed jTextField1.setText(v.Risultato(jTextField1.getText())); }//GEN-LAST:event_jButtonUgualeActionPerformed private void jButtonMoltiplicazioneActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonMoltiplicazioneActionPerformed boolean isErrore; contatoreOP++; jTextField1.setText(v.SchermoOp("")); isErrore=v.Errori(contatoreOP); if(isErrore){ jLabelErrore.setVisible(true); contatoreOP--; }else{ v.Moltiplicazione(jTextField1.getText()); } }//GEN-LAST:event_jButtonMoltiplicazioneActionPerformed private void jButtonDivisioneActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonDivisioneActionPerformed boolean isErrore;
contatoreOP++; jTextField1.setText(v.SchermoOp("")); isErrore=v.Errori(contatoreOP); if(isErrore){ jLabelErrore.setVisible(true); contatoreOP--; }else{ v.Divisione(jTextField1.getText()); } }//GEN-LAST:event_jButtonDivisioneActionPerformed private void jButtonSottrazioneActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSottrazioneActionPerformed boolean isErrore; contatoreOP++; jTextField1.setText(v.SchermoOp("")); isErrore=v.Errori(contatoreOP); if(isErrore){ jLabelErrore.setVisible(true); contatoreOP--; }else{ v.Sottrazione(jTextField1.getText()); } }//GEN-LAST:event_jButtonSottrazioneActionPerformed private void jButtonVirgolaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonVirgolaActionPerformed jTextField1.setText(v.Schermo(".")); }//GEN-LAST:event_jButtonVirgolaActionPerformed private void jButtonCancellaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCancellaActionPerformed v.Cancella(); jTextField1.setText(""); contatoreOP--; }//GEN-LAST:event_jButtonCancellaActionPerformed private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed }//GEN-LAST:event_jTextField1ActionPerformed
v.TAN(jTextField1.getText()); }//GEN-LAST:event_jButtonTANActionPerformed private void jButtonRadiceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonRadiceActionPerformed v.RADICE(jTextField1.getText()); }//GEN-LAST:event_jButtonRadiceActionPerformed private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton10ActionPerformed v.RADennesima(jTextField1.getText()); }//GEN-LAST:event_jButton10ActionPerformed private void jButtonElevamentoNActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonElevamentoNActionPerformed v.elevaN(jTextField1.getText()); }//GEN-LAST:event_jButtonElevamentoNActionPerformed private void jButtonReciprocoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonReciprocoActionPerformed v.Reciproco(jTextField1.getText()); }//GEN-LAST:event_jButtonReciprocoActionPerformed private void jButtonFattorialeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonFattorialeActionPerformed v.Fattoriale(jTextField1.getText()); }//GEN-LAST:event_jButtonFattorialeActionPerformed private void jButtonMemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonMemActionPerformed v.Mem(jTextField1.getText()); //mette un valore in memoria }//GEN-LAST:event_jButtonMemActionPerformed private void jButtonMActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonMActionPerformed v.M(jTextField1.getText()); //somma al valore in memoria un numero }//GEN-LAST:event_jButtonMActionPerformed private void jButtonStoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonStoActionPerformed jTextField1.setText(v.Sto()); //stampa valore in memoria }//GEN-LAST:event_jButtonStoActionPerformed /**
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.