Modifynbspthe payroll program so that it uses a class to


Modify the Payroll Program so that it uses a class to store and retrieve the employee's name, the hourly rate, and the number of hours worked. Use a constructor to initialize the employee information, and a method within that class to calculate the weekly pay. Once stop is entered as the employee name, the application should terminate. Make sure the program maintains all the functionality required in previous assignments and your source code is readable and well documented. Use feedback you have received from the instructor to make any needed modifications.


The application compiles and runs.

The application properly uses a class for employee information.

The application uses a constructor to initialize the employee information and a method within the class to calculate the weekly pay.

The source code is readable and well documented.

The application performs all the required functionality from previous weeks.

 

This is what I already have: 

 

package It215week2;

import java.util.*;
/**
* Monitors employees weekly salary when enter and bonus amount
* Loop feature add
* Program will continue to until user enter "stop" then program will terminate
*
* @author John Doe
*/
public class PayrollSystemProgram {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scanner = new Scanner(System.in);
try {
// requests the user input the name of the employee, the hourly
// rate, and the number of hours worked.
System.out.print("Enter the name of Employee:");
String employeeName = scanner.nextLine();
while(!employeeName .equals("stop"))
{
System.out.print("Hourly Rate : $");
double hourRate = scanner.nextDouble();
while(hourRate {
System.out.println("Hourly Rate should be a positive value.");
System.out.print("Hourly Rate : $");
hourRate = scanner.nextDouble();
}
System.out.println("Number of hours worked :");
int hoursWorked = scanner.nextInt();
while(hoursWorked {
System.out.println("Hourly Rate should be a positive value.");
System.out.println("Number of hours worked :");
hoursWorked = scanner.nextInt();
}
double weeklyPay = 0, bonusPay = 0;
// calculating weekly pay and bonus pay
if (hoursWorked > 40) {
// if hourly worked is more than 40
// then The bonus amount is the number of hours more than 40
// times the hourly rate
weeklyPay = (double) hourRate * hoursWorked;
bonusPay = (double) (hoursWorked - 40) * hourRate * 0.5;
} else {
weeklyPay = (double) hourRate * hoursWorked;
}
// name of the employee and the correct weekly pay amount in dollar
// format and bonus amount in dollar format
System.out.println("***WEEKLY PAY***");
System.out.println("-----------------");
System.out.println("Employee Name:" + employeeName);
System.out.println("Weekly pay amount :$" + weeklyPay);
if (bonusPay != 0) {
System.out.println("Bonus amount :$" + bonusPay);
}
System.out.print("Enter the name of Employee:");
scanner.nextLine();
employeeName = scanner.nextLine();
}
} catch (Exception e) {
// TODO: handle exception
} finally {
scanner.close();
}
}
}

Request for Solution File

Ask an Expert for Answer!!
Basic Computer Science: Modifynbspthe payroll program so that it uses a class to
Reference No:- TGS01185851

Expected delivery within 24 Hours