469,602 Members | 1,725 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,602 developers. It's quick & easy.

Payroll Program

1 Bit
Good day!
I'm new to programming.
Can you guys help me on how to make a simple program that will display the employees name and how to let user enter the rate(pay) per hour and the number of hours worked separated by spaces only and then it'll calculate the wage, cause this part is makes me confused what to used to run...
Thank you so much!!

Hello guys ! Please help me how to separate this code into four class, i really dont know what to do??

Expand|Select|Wrap|Line Numbers
  1. import java.text.DecimalFormat;
  2.  
  3. import java.util.*;
  4.  
  5. public class EmployeeClass {
  6.  
  7.   private static DecimalFormat df2 = new DecimalFormat("#.##");
  8.  
  9.   public static void main(String[] args) {
  10.  
  11.       Scanner input = new Scanner(System.in);
  12.  
  13.           System.out.println("\n");
  14.           System.out.print("\tEnter Name : \n");
  15.           String name = input.nextLine();
  16.  
  17.           System.out.print("\tPress F for Full Time or P for Part Time: \n");
  18.  
  19.           char job_criteria =input.next().charAt(0);
  20.           char select = Character.toUpperCase(job_criteria);          
  21.  
  22.           if (select == 'F') {
  23.             System.out.print("\tEnter Basic Pay :  ");
  24.               double monthlySalary = input.nextDouble();
  25.               System.out.println("\n");
  26.               System.out.println("\tName :  " + name );
  27.               System.out.println("\tMonthly Salary :  " + df2.format(monthlySalary));
  28.               System.out.println("\n");
  29.  
  30.               } else if (select == 'P') {
  31.             System.out.print("\tEnter rate per hour and hours worked separated by spaces:\n");
  32.               double ratePerHour = input.nextDouble();     
  33.               int hoursWorked = input.nextInt();
  34.               double wage =  (ratePerHour * hoursWorked); 
  35.               System.out.println("\n");
  36.               System.out.println("\tEnter Name: " + name );
  37.               System.out.println("\tWage: PHP " + df2.format(wage));
  38.               System.out.println("\n");
  39.  
  40.           } else {
  41.             System.out.println("\n");
  42.             System.out.print("\tInvalid Option. Please Try Again");
  43.              }
  44.  
  45.          System.out.print("\tEnd of Program");
  46.           System.out.println("\n");
  47.  
  48.      }     
  49.   }
Oct 24 '21 #1
1 6290
dev7060
519 Expert 512MB
Expand|Select|Wrap|Line Numbers
  1. import java.text.DecimalFormat;
  2.  
  3. import java.util.*;
  4.  
  5. public class EmployeeClass {
  6.  
  7. private static DecimalFormat df2 = new DecimalFormat("#.##");
  8.  
  9. public static void main(String[] args) {
  10.  
  11. Scanner input = new Scanner(System.in);
  12.  
  13. System.out.println("\n");
  14. System.out.print("\tEnter Name : \n");
  15. String name = input.nextLine();
  16.  
  17. System.out.print("\tPress F for Full Time or P for Part Time: \n");
  18.  
  19. char job_criteria =input.next().charAt(0);
  20. char select = Character.toUpperCase(job_criteria);
  21.  
  22. if (select == 'F') {
  23. System.out.print("\tEnter Basic Pay : ");
  24. double monthlySalary = input.nextDouble();
  25. System.out.println("\n");
  26. System.out.println("\tName : " + name );
  27. System.out.println("\tMonthly Salary : " + df2.format(monthlySalary));
  28. System.out.println("\n");
  29.  
  30. } else if (select == 'P') {
  31. System.out.print("\tEnter rate per hour and hours worked separated by spaces:\n");
  32. double ratePerHour = input.nextDouble();
  33. int hoursWorked = input.nextInt();
  34. double wage = (ratePerHour * hoursWorked);
  35. System.out.println("\n");
  36. System.out.println("\tEnter Name: " + name );
  37. System.out.println("\tWage: PHP " + df2.format(wage));
  38. System.out.println("\n");
  39.  
  40. } else {
  41. System.out.println("\n");
  42. System.out.print("\tInvalid Option. Please Try Again");
  43. }
  44.  
  45. System.out.print("\tEnd of Program");
  46. System.out.println("\n");
  47.  
  48. }
  49. }
Please help me how to separate this code into four class
Why? Based on what?
Also this isn't javascript.
Oct 24 '21 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Randi | last post: by
2 posts views Thread by alexlunar | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.