Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2014
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. import javax.swing.JOptionPane;
  2.  
  3. public class PayrollDialog
  4. {
  5. public static void main ( String[] args )
  6. {
  7. String name, // The user's name
  8. inputString; // To hold input
  9. int hours; // Hours worked
  10. double payRate, // Hourly pay rate
  11. grossPay; // Gross pay
  12. // Get the user's name.
  13. name = JOptionPane.showInputDialog( "What is your name?" );
  14.  
  15. // Get the hours worked.
  16. inputString = JOptionPane.showInputDialog( "How many hours " +
  17. " did you work this week?" );
  18. hours = Integer.parseInt( inputString );
  19.  
  20. // Get the hourly pay rate.
  21. inputString = JOptionPane.showInputDialog( "What is your " +
  22. "hourly pay rate?" );
  23. payRate = Double.parseDouble( inputString );
  24. // Calculate the gross pay.
  25. grossPay = hours * payRate;
  26.  
  27. // Display the results.
  28. JOptionPane.showMessageDialog( null, "Hello " + name +
  29. ". Your gross pay is $" + grossPay );
  30.  
  31. // End the program.
  32. System.exit( 0 );
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement