Create a class called payroll. instance variables are the name of the employee, the hours person worked and the hourly rate. make sure to include try-catch for the constructor, getter, setter methods. when creating an object, the name cannot be empty string, hours worked cannot be negative and cannot be greater than 56 hours. the hourly rate cannot be negative. also include a method called raise that increase the employee hourly rate. the raise cannot be negative. must use try catch

Respuesta :

So creating code a class called payroll. and complementing with the information given in the edict, found that it will be:

Writing code in JAVA:

import java.util.Scanner;

public class payroll

{

   String name;

   double salary;

   double da;

   double hra;

   double pf;

   double grossSal;

   double netSal;    

   public Pay(String n, double s) {

       name = n;

       salary = s;

       da = 0;

       hra = 0;

       pf = 0;

       grossSal = 0;

       netSal = 0;

   }    

   void calculate() {

       da = salary * 15.0 / 100;

       hra = salary * 10.0 / 100;

       pf = salary * 12.0 / 100;

       grossSal = salary + da + hra;

       netSal = grossSal - pf;

   }    

   void display() {

       System.out.println("Employee Name: " + name);

       System.out.println("Salary: " + salary);

       System.out.println("Dearness Allowance: " + da);

       System.out.println("House Rent Allowance: " + hra);

       System.out.println("Provident Fund: " + pf);

       System.out.println("Gross Salary: " + grossSal);

       System.out.println("Net Salary: " + netSal);

   }    

   public static void main(String args[]) {

       Scanner in = new Scanner(System.in);

       System.out.print("Enter Employee Name: ");

       String empName = in.nextLine();

       System.out.print("Enter Salary: ");

       double empSal = in.nextDouble();        

      payroll = new Pay(empName, empSal);

       obj.calculate();

       obj.display();

   }

}

See more about JAVA code at brainly.com/question/12975450

#SPJ1

Ver imagen lhmarianateixeira
ACCESS MORE
EDU ACCESS