Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Question: My UML: My code: import java.util.Scanner; public class Payroll { priv

ID: 3548697 • Letter: Q

Question

Question:


My UML:



My code:

import java.util.Scanner;

public class Payroll
{
    private String Employee_name="";
    private int ID=0;
    private float hourly_pay_rate=0;
    private int no_hours=0;
    
    public Payroll()
    {
        
    }
    
    public Payroll(String Employee_name,int ID, float hourly_pay_rate, int no_hours)
    {
        
        this.Employee_name=Employee_name;
        this.ID = ID;
        this.hourly_pay_rate = hourly_pay_rate;
        this.no_hours=no_hours;
        
    }
    
    public String getEmployee_name()
    {
        return Employee_name;
    }
    
    public int getID()
    {
        return ID;
    }
    
    public float gethourly_pay_rate()
    {
        return hourly_pay_rate;
    }
    
    public int getno_hours()
    {
        return no_hours;
    }
    
    public void setEmployee_name()
    {
        this.Employee_name=Employee_name;
    }
    
    public void setID()
    {
        this.ID=ID;
    }
    
    public void sethourly_pay_rate()
    {
        this.hourly_pay_rate=hourly_pay_rate;
    }
    
    public void setno_hours()
    {
        this.no_hours=no_hours;
    }
        
    public static float getGrossPay(float hourly_pay_rate, int no_hours)
    {
        
        float total=0;
        
        total=hourly_pay_rate*no_hours;
        
        return total;
        
    }
    
    public static void main(String [] args)
    {
     
        
        
        Payroll pay = new Payroll();
        
        Scanner input = new Scanner(System.in);
        
        System.out.println("Enter employee name: ");
        Employee_name = input.next();
        System.out.println("Enter employee ID: ";
        ID = input.nextInt();
        System.out.println("Enter pay rate: ");
        System.out.println("Enter work hours:");
        
    
        
    }
}


Please correct my code, and using comment to explain wrong
i do half and don no how to continous.

Please answer full code with comment.



Draw the UML class diagram for Payroll class with the following descriptions. The class contains: Private field/data: Employee's name ID number Hourly pay rate Number of hours worked (should be whole number) Public constructors: A no-argument constructor that create a default payroll object. A constructor that accepts the employee's name and ID number as arguments. Public methods: Accessor methods for all data fields. Mutator methods for all data fields. A method named getGrossPay () that returns the employee's gross pay per week, which is calculated as the number of worked multiplied by the hourly pay rate. Write the Payroll class and then write a test program that demonstrates the class by creating a Payroll object. Prompt the user to input all the data for an employee. Then display the details together with the amount of gross pay earned. The sample output is as shown in Figure C1. Sample output: Enter employee name: Lily Enter employee ID: AC102922 Enter the pay rate:$ 3.50 Enter the hours worked: 40 Employee name: Lily Employee ID: AC102922 Pay Rate:$ 3.50 Hours Worked: 40 Gross Pay (a week): $ 140.00 Payroll - Employee - name : string - ID : int - Hourly-pay-rate : float - Number of hours worked : int + Payroll ( ) + Payroll (Employee name: string, ID: int, Hourly-pay-rate: float, Number of hours worked : int) + get employee-name ( ): string + get ID ( ): int + get Hourly pay-rate ( ): float + get Number of Hours worked ( ) : int + get Employee-name ( ) : string + set ID ( ): int + set Hourly pay-rate ( ): float + set Number of Hours worked ( ) : int + get Gross pay ( ): void

Explanation / Answer

import java.util.Scanner;
public class Payroll
{
// u have to intialize variables only in constructor.
private String Employee_name;
private String ID;
private float hourly_pay_rate;
private int no_hours;
public Payroll()
{
Employee_name="";
ID="";
hourly_pay_rate=0;
no_hours=0;
}
public Payroll(String Employee_name,String ID)
{
this.Employee_name=Employee_name;
this.ID = ID;
}
public String getEmployee_name()
{
return Employee_name;
}
public String getID()
{
return ID;
}
public float gethourly_pay_rate()
{
return hourly_pay_rate;
}
public int getno_hours()
{
return no_hours;
}
public void setEmployee_name(String Employee_name)
{
this.Employee_name=Employee_name;
}
public void setID(String ID)
{
this.ID=ID;
}
public void sethourly_pay_rate(float hourly_pay_rate)
{
this.hourly_pay_rate=hourly_pay_rate;
}
public void setno_hours(int no_hours)
{
this.no_hours=no_hours;
}
public float getGrossPay()
{
return hourly_pay_rate*no_hours;
}
public static void main(String [] args)
{
Payroll pay = new Payroll();
Scanner input = new Scanner(System.in);
System.out.println("Enter employee name: ");
String employee_name = input.next();
pay.setEmployee_name(employee_name);
System.out.println("Enter employee ID: ");
String ID = input.next();
pay.setID(ID);
System.out.println("Enter pay rate: ");
float pay_rate = (float)input.nextDouble();
pay.sethourly_pay_rate(pay_rate);
System.out.println("Enter work hours:");
int no_hours = input.nextInt();
pay.setno_hours(no_hours);

System.out.println(" Employee Name :" + pay.getEmployee_name());
System.out.println("Employee ID :" + pay.getID());
System.out.println("Pay Rate :$" + pay.gethourly_pay_rate());
System.out.println("Hours Worked :" + pay.getno_hours());
System.out.println("Gross Pay(a week) :$" + pay.getGrossPay());

}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote