import java.io.*;
import java.util.*;
public class PayCheck
{
public static void main (String[] args)
{
//outputs
}
}
class ReadData
{
//input from different file
private String names [];
private double payRate [];
private double hours [];
ReadData(String[] names, double [] payRate, double [] hours) throws IOException
{
names = new String [4];
payRate = new double [4];
hours = new double [4];
readFile(names, payRate, hours);
}
public static void readFile(String names [], double payRate [], double hours []) throws IOException
{
File nameRead = new File ("names.txt");//read from text file
Scanner inName = new Scanner (nameRead);
File hourRead = new File ("hours.txt");
Scanner inHours = new Scanner (hourRead);
File payRead = new File ("payrates.txt");
Scanner inPays = new Scanner (payRead);
while (inName.hasNextLine())
{
for (int i = 0; i < names.length; i++)
{
names [i] = inName.nextLine();
}
}
while (inPays.hasNextLine())
{
for (int j = 0; j< payRate.length; j++)
{
payRate [j] = Double.parseDouble(inPays.nextLine());
}
}
while (inHours.hasNextLine())
{
for (int k = 0; k< hours.length; k++)
{
hours [k] = Double.parseDouble(inHours.nextLine());
}
}
}
}//end class
//put this in main?
class WriteNet
{
private double netPays[];
private double netTotal = 0.0;
private String names[];
WriteNet(double [] netPays, String [] names, double netT) throws IOException
{
this.netPays = netPays;
this.names = names;
netTotal = netT;
calcTotal(netPays);
writeFile(netPays, names, netTotal);
}
private double calcTotal(double netPays[])
{
for (int c = 0; c< netPays.length; c++)
{
netTotal += netPays[c];
}
return netTotal;
}
public static void writeFile(double netPays[], String names [], double netTotal) throws IOException
{
PrintWriter out = new PrintWriter (new FileWriter("Netpays.txt"));
out.println("Netpays");
for (int x =0; x< netPays.length; x++)
{
out.println(names [x] + " " + netPays[x]);//write each employee's net pay
}
out.println("Total NetPay: " + netTotal);
out.close();
}//end write method
}//end class
class GrossPay
{
private double hours [];
private double payRate [];
private double grossPays [];
GrossPay (double [] hours, double [] payRate, double [] grossPays)
{
this.hours = hours;
this.payRate = payRate;
grossPays = new double [4];
gross (hours, payRate, grossPays);
}
private void gross (double hours [], double payRate [], double grossPays [])
{
for (int x = 0; x <grossPays.length; x++)
{
grossPays[x] = hours [x] * payRate [x];
Math.round(grossPays[x]);
}
}
double getGross ()
{
//how to return?
return grossPays;
}
}//end gross class
class EmployeeTax //individual employee
{
private double fedTax = 0.17;
private double provTax = 0.14;
private double grossPays [];
private double empTaxes[];
private double proTax[];
private double feTax[];
EmployeeTax (double fTax, double pTax, double [] grossPays, double [] empTaxes, double [] proTax, double []feTax)
{
fedTax = fTax;
provTax = pTax;
this.grossPays = grossPays;
this.empTaxes = empTaxes;
this.proTax = proTax;
this.feTax = feTax;
tax (grossPays, empTaxes, proTax, feTax, fedTax, provTax);
}
private void tax (double grossPays [], double empTaxes[], double [] proTax, double [] feTax, double fedTax, double provTax)
{
for (int y = 0; y < empTaxes.length; y++)
{
double pTax = grossPays[y] * provTax;
double fTax = grossPays[y] * fedTax;
double taxDeduct = pTax + fTax;
empTaxes [y] = Math.round(taxDeduct); //total
proTax[y] = Math.round(pTax); //provincial tax
feTax[y] = Math.round(fTax); //federal tax
}
}
double getTax()
{
return;
}
}//end tax class
class EmployeeNet
{
private double grossPays[];
private double empTaxes[];
private double netPays[];
EmployeeNet (double [] grossPays, double [] empTaxes, double [] netPays)
{
this.grossPays = grossPays;
this.empTaxes = empTaxes;
this.netPays = netPays;
net(grossPays, empTaxes, netPays);
}
private void net(double grossPays [], double empTaxes [], double netPays [])
{
for (int z = 0; z < 4; z++)
{
netPays [z] = grossPays[z] - empTaxes[z];
}
}
double getNet()
{
//
}
}//end net