Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void clear_buttActionPerformed(java.awt.event.ActionEvent evt) {
- // TODO add your handling code here:
- num_text.setText("");
- out_text.setText("");
- }
- private void exit_buttActionPerformed(java.awt.event.ActionEvent evt) {
- // TODO add your handling code here:
- System.exit(busyIconIndex);
- }
- private void out_textActionPerformed(java.awt.event.ActionEvent evt) {
- }
- private void fact_buttActionPerformed(java.awt.event.ActionEvent evt) {
- // TODO add your handling code here:
- //Declare variables
- String fact_out;
- int total, k, num;
- //initiliaze for invalid data
- num = 1;
- if ((num_text.getText().equals("")))
- { num_text.setText("");
- //put error message out
- JOptionPane.showMessageDialog(null, "Lack of information!", "Error message", JOptionPane.ERROR_MESSAGE );
- }
- else
- {
- //get the information off the form
- num = Integer.parseInt(num_text.getText());
- //Calculate
- total = 1;
- for (k = 1; k <= num; k++)
- total = total * k;
- //Put results on forum
- out_text.setText(String.valueOf(num) + "! is equal to " + String.valueOf(total) );
- if ((num <0))
- { num_text.setText("");
- out_text.setText("");
- //put error message out
- JOptionPane.showMessageDialog(null, "You entered a negative number", "Error message", JOptionPane.ERROR_MESSAGE );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement