Payroll Program

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Marylou17
    New Member
    • Oct 2021
    • 1

    Payroll Program

    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??

    Code:
    import java.text.DecimalFormat;
    
    import java.util.*;
    
    public class EmployeeClass {
      
      private static DecimalFormat df2 = new DecimalFormat("#.##");
    
      public static void main(String[] args) {
        
          Scanner input = new Scanner(System.in);
              
              System.out.println("\n");
              System.out.print("\tEnter Name : \n");
              String name = input.nextLine();
              
              System.out.print("\tPress F for Full Time or P for Part Time: \n");
              
              char job_criteria =input.next().charAt(0);
              char select = Character.toUpperCase(job_criteria);          
              
              if (select == 'F') {
                System.out.print("\tEnter Basic Pay :  ");
                  double monthlySalary = input.nextDouble();
                  System.out.println("\n");
                  System.out.println("\tName :  " + name );
                  System.out.println("\tMonthly Salary :  " + df2.format(monthlySalary));
                  System.out.println("\n");
                 
                  } else if (select == 'P') {
                System.out.print("\tEnter rate per hour and hours worked separated by spaces:\n");
                  double ratePerHour = input.nextDouble();     
                  int hoursWorked = input.nextInt();
                  double wage =  (ratePerHour * hoursWorked); 
                  System.out.println("\n");
                  System.out.println("\tEnter Name: " + name );
                  System.out.println("\tWage: PHP " + df2.format(wage));
                  System.out.println("\n");
    
              } else {
                System.out.println("\n");
                System.out.print("\tInvalid Option. Please Try Again");
                 }
              
             System.out.print("\tEnd of Program");
              System.out.println("\n");
        
         }     
      }
    Last edited by Niheel; Oct 25 '21, 05:20 PM. Reason: Merged the posts into one question.
  • dev7060
    Recognized Expert Contributor
    • Mar 2017
    • 656

    #2
    Code:
    import java.text.DecimalFormat;
    
    import java.util.*;
    
    public class EmployeeClass {
    
    private static DecimalFormat df2 = new DecimalFormat("#.##");
    
    public static void main(String[] args) {
    
    Scanner input = new Scanner(System.in);
    
    System.out.println("\n");
    System.out.print("\tEnter Name : \n");
    String name = input.nextLine();
    
    System.out.print("\tPress F for Full Time or P for Part Time: \n");
    
    char job_criteria =input.next().charAt(0);
    char select = Character.toUpperCase(job_criteria);
    
    if (select == 'F') {
    System.out.print("\tEnter Basic Pay : ");
    double monthlySalary = input.nextDouble();
    System.out.println("\n");
    System.out.println("\tName : " + name );
    System.out.println("\tMonthly Salary : " + df2.format(monthlySalary));
    System.out.println("\n");
    
    } else if (select == 'P') {
    System.out.print("\tEnter rate per hour and hours worked separated by spaces:\n");
    double ratePerHour = input.nextDouble();
    int hoursWorked = input.nextInt();
    double wage = (ratePerHour * hoursWorked);
    System.out.println("\n");
    System.out.println("\tEnter Name: " + name );
    System.out.println("\tWage: PHP " + df2.format(wage));
    System.out.println("\n");
    
    } else {
    System.out.println("\n");
    System.out.print("\tInvalid Option. Please Try Again");
    }
    
    System.out.print("\tEnd of Program");
    System.out.println("\n");
    
    }
    }
    Please help me how to separate this code into four class
    Why? Based on what?
    Also this isn't javascript.

    Comment

    Working...