First of all, I might think you have copied the program from an external source,
since there is lots of compilation errors.
Anyways…
try this this might work…
import java.util.Scanner;
public class DemoPayroll {
public static void main(String[] args) {
Payroll newEmpInfoObject = new Payroll();
System.out.println("Enter name");
Scanner keyboard = new Scanner(System.in);
String name = keyboard.nextLine();
System.out.println("Enter Address");
String address = keyboard.nextLine();
System.out.println("Enter Hourly Pay");
double payrate = keyboard.nextDouble();
System.out.println("Enter Hours Worked");
double hours = keyboard.nextDouble();
System.out.println("Enter Weeks");
int week = keyboard.nextInt();
Payroll pay=new Payroll();
pay.printEmpInfo(name,address);
System.out.println(pay.getGrossPayEarned(payrate,hours,week));
}
}
class Payroll {
private double payrate;
private double hours;
public Object printEmpInfo(String name,String address) {
System.out.println(name);
System.out.println(address);
return address;
}
public double getGrossPayEarned(double payrate,double hours,int week) {
return (hours)*((hours/week)*52)/12;
}
}
solved New to coding and getters and setters are not working to a new class? [closed]