Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2014
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. import java.util.Scanner;
  2. import java.text.DecimalFormat;
  3.  
  4. public class Commission
  5. {
  6. public static void main ( String [] args )
  7. {
  8. Scanner keyboard = new Scanner(System.in);
  9. String employeeName;
  10. double plansSold, salary = 0, receivedCommission = 0, total = 0;
  11. final double lowCommission = 0.005, medCommission = 0.0075, hiCommission = 0.01;
  12. int hoursWorked;
  13. System.out.print("What is the employee's name?");
  14. employeeName = keyboard.nextLine();
  15. System.out.print("How many hours worked?");
  16. hoursWorked = keyboard.nextInt();
  17. System.out.print("Enter total value of monthly plans sold today: ");
  18. plansSold = keyboard.nextDouble();
  19.  
  20. salary = hoursWorked * 10;
  21.  
  22. if(plansSold <= 1000)
  23. {
  24. receivedCommission = plansSold * lowCommission;
  25. }
  26. else if(plansSold > 1000 && plansSold <= 2000)
  27. {
  28. receivedCommission = plansSold * medCommission;
  29. }
  30. else if(plansSold > 2000)
  31. {
  32. receivedCommission = plansSold * hiCommission;
  33. }
  34.  
  35. total = receivedCommission + salary;
  36. System.out.printf("%10s%10s%10s%10s", "Hours", "Salary", "Comm", "Total\n");
  37. System.out.printf("%10d%10.1f%10.1f%10.1f", hoursWorked, salary, receivedCommission, total);
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement