Guest User

Untitled

a guest
Jun 19th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. import javax.swing.JOptionPane;
  2.  
  3.  
  4.  
  5. public class SalaryCalculator
  6.  
  7. {
  8.  
  9. public static void main ( String args [] )
  10.  
  11. {
  12.  
  13. int counter = 1;
  14.  
  15. String name;
  16.  
  17. double hours;
  18.  
  19. double rate;
  20.  
  21. double pay;
  22.  
  23. int salary;
  24.  
  25.  
  26. while (counter <=3)
  27.  
  28. {
  29.  
  30. name = JOptionPane.showInputDialog( "Enter name");
  31.  
  32. hours = Double.parseDouble(JOptionPane.showInputDialog( "Enter hours"));
  33.  
  34. rate = Double.parseDouble(JOptionPane.showInputDialog( "Enter rate"));
  35.  
  36.  
  37.  
  38. if ( hours>40 )
  39.  
  40. pay = (40 * rate) + (hours - 40) *rate * 1.5;
  41.  
  42. else
  43.  
  44. pay = hours * rate;
  45.  
  46.  
  47.  
  48. counter = counter +1;
  49.  
  50.  
  51.  
  52.  
  53.  
  54. }
  55. //this needs a message type argument:
  56. //JOptionPane.showMessageDialog(Component parentComponent , String string, int messageType}
  57. JOptionPane.showMessageDialog(null, name);
  58.  
  59. //this should give you a centered information dialog
  60. JOptionPane.showMessageDialog(null, name, JOptionPane.INFORMATION_MESSAGE);
  61. System.exit(0);
  62. }
  63.  
  64. }
Add Comment
Please, Sign In to add comment