Advertisement
Guest User

skjfg

a guest
Nov 24th, 2014
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.13 KB | None | 0 0
  1.     private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {                                      
  2.  
  3.         Float Total;
  4.         Float Change;
  5.         Double Amnt = new Double(SaleAmt.getText());
  6.         Double Cash = new Double(CashAmt.getText());
  7.  
  8.         Cash *= 100;
  9.         Amnt *= 100;
  10.         Change = Cash.floatValue() - Amnt.floatValue();
  11.  
  12.         Total = Cash.floatValue() - Amnt.floatValue();
  13.         ChngDue.setText("$" + new Float(Change/100).toString());
  14.         twenty.setText(new Integer(Total.intValue() / 2000).toString());
  15.         Total %= 2000;
  16.         ten.setText(new Integer(Total.intValue() / 1000).toString());
  17.         Total %= 1000;
  18.         five.setText(new Integer(Total.intValue() / 500).toString());
  19.         Total %= 500;
  20.         two.setText(new Integer(Total.intValue() / 200).toString());
  21.         Total %= 200;
  22.         dollar.setText(new Integer(Total.intValue() / 100).toString());
  23.         Total %= 100;
  24.         twentyfivecent.setText(new Integer(Total.intValue() / 25).toString());
  25.         Total %= 25;
  26.         tencent.setText(new Integer(Total.intValue() / 10).toString());
  27.         Total %= 10;
  28.         fivecent.setText(new Integer(Total.intValue() / 5).toString());
  29.         Total %= 5;
  30.         onecent.setText(new Integer(Total.intValue() / 1).toString());
  31.         Total %= 1;
  32.  
  33.      /**
  34.      * @param args the command line arguments
  35.      */
  36.     public static void main(String args[]) {
  37.         /* Set the Nimbus look and feel */
  38.         //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  39.         /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  40.          * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  41.          */
  42.         try {
  43.             for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  44.                 if ("Nimbus".equals(info.getName())) {
  45.                     javax.swing.UIManager.setLookAndFeel(info.getClassName());
  46.                     break;
  47.                 }
  48.             }
  49.         } catch (ClassNotFoundException ex) {
  50.             java.util.logging.Logger.getLogger(Changecalc.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  51.         } catch (InstantiationException ex) {
  52.             java.util.logging.Logger.getLogger(Changecalc.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  53.         } catch (IllegalAccessException ex) {
  54.             java.util.logging.Logger.getLogger(Changecalc.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  55.         } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  56.             java.util.logging.Logger.getLogger(Changecalc.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  57.         }
  58.         //</editor-fold>
  59.  
  60.         /* Create and display the form */
  61.         java.awt.EventQueue.invokeLater(new Runnable() {
  62.             public void run() {
  63.                 new Changecalc().setVisible(true);
  64.             }
  65.         });
  66.     }
  67.     // Variables declaration - do not modify                    
  68.     private javax.swing.JTextField CashAmt;
  69.     private javax.swing.JTextField ChngDue;
  70.     private javax.swing.JTextField SaleAmt;
  71.     private javax.swing.JTextField dollar;
  72.     private javax.swing.JTextField five;
  73.     private javax.swing.JTextField fivecent;
  74.     private javax.swing.JButton jButton1;
  75.     private javax.swing.JLabel jLabel1;
  76.     private javax.swing.JLabel jLabel10;
  77.     private javax.swing.JLabel jLabel2;
  78.     private javax.swing.JLabel jLabel3;
  79.     private javax.swing.JLabel jLabel4;
  80.     private javax.swing.JLabel jLabel5;
  81.     private javax.swing.JLabel jLabel6;
  82.     private javax.swing.JLabel jLabel7;
  83.     private javax.swing.JLabel jLabel8;
  84.     private javax.swing.JLabel jLabel9;
  85.     private javax.swing.JTextField onecent;
  86.     private javax.swing.JTextField ten;
  87.     private javax.swing.JTextField tencent;
  88.     private javax.swing.JTextField twenty;
  89.     private javax.swing.JTextField twentyfivecent;
  90.     private javax.swing.JTextField two;
  91.     // End of variables declaration                  
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement