I'm trying to read in the following text file:
Jim Nasium
mgr
Fitness & Leisure
45000
Lazy Susan
mgr
Home Furnishings
55000
Gene Theory
mgr
Fine Jewelry
10000
And I have the following code:
public abstract class Employee {
private String name;
private double grossPay;
private double netPay;
private final double TAX_RATE = 28.0;
/* Constructors */
public Employee() {
}
abstract public void computePay();
public double computeTax() {
return (TAX_RATE/100.0)*grossPay;
}
public String toString() {
String retString = "";
retString = "Name: " + this.getName() + "n";
retString += "Gross Salary: " + this.grossPay + "n";
retString += "Tax: " + computeTax() + "n";
retString += "Net Salary: " + this.netPay + "n";
return retString;
}
public void setNetPay(double pay) {
this.netPay = pay;
}
public double getNetPay() {
return netPay;
}
public void setGrossPay(double pay) {
this.grossPay = pay;
}
public double getGrossPay() {
return grossPay;
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
public class Managers extends Employee implements Bonuses {
private String department;
private double bonus;
private final double BONUS_RATE = 1.0;
private String name;
private String jobType;
private Double income;
private double tax;
/* Constructors */
public Managers()
{
}
public void inputInfo(String s, String inL)
{
if(s.equals("name"))
name = inL;
else if(s.equals("title"))
jobType = inL;
else if(s.equals("department"))
department = inL;
else if(s.equals("salary"))
income = Double.parseDouble(inL);
}
@Override
public double calcBonus() {
this.setGrossPay((income/24) + this.bonus);
this.bonus = (income/24)*(BONUS_RATE/100);
return bonus;
}
@Override
public void computePay() {
this.setGrossPay((income/24) + this.bonus);
tax = this.computeTax();
this.setNetPay(income/24 + this.bonus - tax);
}
public String printInfo() {
String s = "";
s += name + " " + jobType + " " + income + " " + this.getGrossPay() + " " + this.getNetPay() + " " + tax;
return s;
}
}
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Scanner;
public class Payrolls
{
public static void main(String[] args)
{
Managers mgr = new Managers();
System.out.println(mgr.printInfo());
//inL = in.readLine();
}
public static void getInfo()throws FileNotFoundException
{
Scanner inF = new Scanner(new File("C:TEMPeclipse-java-indigo-SR1-win32eclipseEmployee.txt"));
while(inF.hasNextLine( ))
{
Managers mgr = new Managers();
mgr.inputInfo("name", inF.nextLine( ));
mgr.inputInfo("title", inF.nextLine( ));
mgr.inputInfo("department", inF.nextLine( ));
mgr.inputInfo("salary", inF.nextLine( ));
mgr.calcBonus();
mgr.computePay();
}
}
}
Yet when I run the program, I get the following output:
null null null 0.0 0.0 0.0