Create a Java file named Ch6Asg.java that contains a public class named Ch6Asg containing a main() method. Within the same file, create another class named Employee, and do not declare it public. Create a field for each of the following pieces of information: employee name, employee number, hourly pay rate, and overtime rate. Create accessor and mutator methods for each field. The mutator method for the hourly pay rate should require the value to be greater than zero. If it is not, set the rate to zero. The overtime rate must be an integer value of zero or higher. If an attempt is made to set it negative, simply set it to zero. Create a constructor that accepts four arguments and calls each mutator method, passing the appropriate argument to each method. Create a method named CalculateWage() that returns the employee’s weekly wage. The method must accept two arguments, each of which is described below. • The first argument should hold the number of hours the employee worked over the pay period. The number of hours worked must be zero or higher. If the value passed to the method is less than zero, display a message that says the number of hours is invalid and return a -1. Note: An even better option is to create and throw an Exception. If you’re familiar with Exceptions, feel free to do so anywhere you find appropriate. • The second argument should hold the shift number that the employee worked. An employee can work first, second, or third shift. Display an error message and return -1 if an attempt is made to set the value to something other than 1, 2, or 3. Employees who work third shift are paid 10% above their hourly pay rate. Here are a few examples of how the method should work. • Suppose an employee works first shift for 45 hours and that he makes 15% extra for overtime. In this case, he would earn 40 * 20 + 5 * 20 * 1.15 = $915. • Now suppose that same employee works third shift for 45 hours instead of first. He would then receive 40 * 20 * 1.10 + 5 * 20 * 1.25 = $1,005. In the main() method, prompt the user for an employee name, number, an hourly pay rate, and a percentage paid for overtime. Using these values, instantiate a new Employee object. Then, prompt the user to provide the number of hours the employee worked, the shift he worked them on, and the percentage paid for overtime. Call the Employee object’s CalculateWage() method, passing the relevant values to it. If the values are valid, display the earnings for the employee. Continue prompting the user for the hourly pay rate, shift, hours worked, and percentage for overtime hours. Use the values to calculate the weekly pay in a loop until the user decides to quit, at which point the program should end. Note: Do not create a new Employee object each time within the loop. If any of the object’s attributes need to change, simply call the appropriate mutator method to change it. When finished with your work, be sure to fully comment your program. Submit it in Blackboard on or before the deadline.
Snapshots:
Code:
import java.util.Scanner;
public class Ch6Asg { //creating a class as
instructed
public static void main(String[] args) { //start of main
method
Ch6Asg a=new Ch6Asg(); //required to access the Employee
class
boolean y=true; //required for the loop
Scanner s=new Scanner(System.in); //required to read input from the
user
System.out.println("Enter Employee name:"); //prompt
user to enter employee name
String name=s.nextLine(); //read employee name
System.out.println("Enter Employee number:"); //prompt user to
enter employee number
String num=s.nextLine(); //read employee number
System.out.println("Enter Employee hourly pay rate:"); //prompt for
hourly pay rate
double hp=s.nextDouble(); //read hourly pay rate
System.out.println("Enetr percentage paid for overtime:"); //prompt
for overtime percentage
double p=s.nextDouble(); //read overtime percentage
Employee e=a.new Employee(name,num,hp,p); //instantiate Employee
object
while(y=true){ //until user wishes to quit loop using while
System.out.println("Enter the number of hours the Employee worked
for:"); //prompt for total number of hours employee worked
for
double h=s.nextDouble(); //read hours
System.out.println("Enter the shift number:1 or 2 or 3:"); //prompt
for shift number
int sh=s.nextInt(); //read shift number
System.out.println("Enetr the percentage extra of overtime:");
//prompt for percentage extra of overtime
p=s.nextDouble(); //read overtime percentage
double totWage=e.calculateWage(h,sh); //calling function to
calculate wages
System.out.println("The wages of Employee are:"+totWage);
//displaying total wages after calculation
}
y=false;
} //end of main
class Employee{ //Beginning of class Employee
//all the required parameters
private String ename,eno;
private double hpr;
private double otr;
//all the required accessors and mutators
public String getEname() {
return ename;
}
public void setEname(String ename) {
this.ename = ename;
}
public String getEno() {
return eno;
}
public void setEno(String eno) {
this.eno = eno;
}
public double getHpr() {
return hpr;
}
public void setHpr(double hpr) {
if(hpr>0){ //condition to be satisfied
this.hpr = hpr;
}
else{
this.hpr=0;
}
}
public double getOtr() {
return otr;
}
public void setOtr(double otr) {
if(otr>0){ //condition to be satisfied
this.otr = otr;
}
else{
this.otr=0;
}
}
//Required constructor
Employee(String ename,String eno,double hpr,double otr){
setEname(ename);
setEno(eno);
setHpr(hpr);
setOtr(otr);
}
//function definition to calculate wages
double calculateWage(double hr,int sn){
double wwage=0;
if(hr<0){
System.out.println("Number of hours is
invalid");
return -1;
}
else{
if(sn==1 || sn==2){
wwage=40*hpr+(hr-40)*hpr*otr; //40 is
minimum number of hours per week for every employee. Overtime hours
is obtained by hpr-40
} //can
change the formula as required
else if(sn==3){ //10% extra for
shift 3
wwage=40*hpr*(1.10)+(hr-40)*hpr*otr*(1.10);
}
else{
System.out.println("Invalid Shift");
return -1;
}
}
return wwage; //return total wage
}
}
}
Output:
Create a Java file named Ch6Asg.java that contains a public class named Ch6Asg containing a main()...
Employee and ProductionWorker Classes DONE IN C# PLEASE Create an Employee class that has properties for the following data: • Employee name • Employee number Next, create a class named ProductionWorker that is derived from the Employee class. The ProductionWorker class should have properties to hold the following data: • Shift number (an integer, such as 1, 2, or 3) • Hourly pay rate The workday is divided into two shifts: day and night. The Shift property will hold an...
Create the Python code for a program adhering to the following specifications. Write an Employee class that keeps data attributes for the following pieces of information: - Employee Name (a string) - Employee Number (a string) Make sure to create all the accessor, mutator, and __str__ methods for the object. Next, write a class named ProductionWorker that is a subclass of the Employee class. The ProductionWorker class should keep data attributes for the following information: - Shift number (an integer,...
You must create a Java class named TenArrayMethods in a file named TenArrayMethods.java. This class must include all the following described methods. Each of these methods should be public and static.Write a method named getFirst, that takes an Array of int as an argument and returns the value of the first element of the array. NO array lists. Write a method named getLast, that takes an Array of int as an argument and returns the value of the last element...
JAVA HELP Design a class named Employee. The class should keep the following information in fields: Employee name Employee number in the format XXX–L, where each X is a digit within the range 0–9 and the L is a letter within the range A–M. Hire date then, Write one or more constructors and the appropriate accessor and mutator methods for the class. Next, write a class named ProductionWorker that extends the Employee class. The ProductionWorker class should have fields to...
This is done in C++ Create an Employee class using a separate header file and implementation file. Review your UML class diagram for the attributes and behaviors The calculatePay() method should return 0.0f. The toString() method should return the attribute values ("state of the object"). Create an Hourly class using a separate header file and implementation file. The Hourly class needs to inherit from the Employee class The calculatePay() method should return the pay based on the number of hours...
Introduction to computer class, Java programming through eclipse: Ue the following criteria to create the code: SALARY Input first and last name - Output the names last, first in your output - Make the federal withholding rate a constant 20% (not an input value) No state tax Generate two new values: regular pay and overtime pay - 40 hours workedor less - Regular pay is pay rate * hours worked - Overtime pay is 0 Otherwise - Regular pay is...
public class EmployeeDriver public static void main(String[] args) 1/declare create an Employee object named joo. Une no-arg constructor 1/change the attributes for joe as the following: //name to Joe Cool, id to 1111111, hours to 20, pay rate to 15 //dealare & create another Employee oblegt named one using arg-constructor // The name of the new employees Jane Doeid is 2001122. She makes $10.50/hour // change the object Jane's hours to 40. 1/change the object jane's pay rate to $12.00....
Design a program(Creating a RAPTOR flowchart) that will read a file of employee records containing employee number, employee name, hourly pay rate, regular hours worked and overtime hours worked. The company pays its employees weekly, according to the following rules: regular pay = regular hours worked × hourly rate of pay overtime pay = overtime hours worked × hourly rate of pay × 1.5 total pay = regular pay + overtime pay Your program is to read the input data...
C++ Visul Studio Create a class named Vehicle. The class has the following five member variables: • Vehicle Name • Vehicle number • Sale Tax • Unit price • Total price Include set (mutator) and get (accessor) functions for each field except the total price field. The set function prompt the user for values for each field. This class also needs a function named computePrice() to compute the total price (quantity times unit price + salesTax) and a function to...
WRITE IN C++ ONLY PLEASE. IM USING VISUAL STUDIO CODE.1. Employee and ProductionWorker ClassesDesign a class named Employee. The class should keep the following information in• Employee name• Employee number• Hire dateWrite one or more constructors and the appropriate accessor and mutator functions for the class.Next, write a class named ProductionWorker that is derived from the Employee class. The ProductionWorker class should have member variables to hold the following information:• Shift (an integer)• Hourly pay rate (a double )The workday...