//////////////////////////////////
//Thomas Kramer - PAY2PROJ////////
//////////////////////////////////

import java.util.Scanner;
import java.text.DecimalFormat;
public class PayrollInput
{

  public static void main(String[] args)
  {

	//1a. Initiate variables
	Scanner entry = new Scanner(System.in);
	String dump = " ";
	boolean del = false;
	boolean Loop = true;
	int ID = 0;
	DecimalFormat formatter = new DecimalFormat("#0.00");

	//1b.Create Employee Class
	TKEmployee e1;
	e1 = new TKEmployee();

while(Loop = true)
	 {
		//Test if it is the first loop:
		if (del == false)
		say("Press enter to begin...");

		//Dump the last line:
		dump = entry.nextLine();

  		say("Please enter the employees ID number:");
		ID = entry.nextInt();
		e1.setCode(ID);
			//Check the ID for an input of 0, then if true report and end program.
			if (ID == 0)
			{
			 e1.report();
			 Loop = false;
			 System.exit(0);
			}

		//dump the line
		dump = entry.nextLine();

		say("Please enter the name of the employee:(Lastname, FirstName):");
		e1.setName(entry.nextLine());

		say("Please enter the pay of the new employee:");
		e1.setPay(entry.nextDouble());
			while(e1.getPay() < 0) //TEST if pay is above 0
			{
			say("0 and below is in invalid payrate, please re-enter the value.");
			e1.setPay(entry.nextDouble());
			}

		say("Please enter the number of hours that the employee has worked:");
		e1.setHours(entry.nextDouble());
			while(e1.getHours() < 0) //TEST if hours are greater then 0, but is acceptable to be 0.
			{
			say("Employee can not work negative hours");
			say("Please enter a valid number of hours, 0 is acceptable");
			e1.setHours(entry.nextDouble());
			}
		say("Employee exempt code? (0,1,2,3,4)");
		e1.setExempt(entry.nextDouble());

		/* while (e1.getExempt() >=4)
		 {
		 say("This is an invalid entry!");
		 say("Please re-enter a valid entry:");
		 exemptStr = entry.nextLine();
		 e1.setExempt(Integer.parseInt(exemptStr));
	     } */

	   //Disable the 'press enter' message:
	   del = true;

	   //Print the check and initate the counter to add
	   e1.printCheck();
	   e1.counter();

	}//while//
  }

  public static void say(String x){System.out.println(x);}

}
/////

/////
///










////////////////////////////////
//Thomas Kramer - PAY2 PROJ/////
////////////////////////////////
import java.util.StringTokenizer;
import java.util.Scanner;
import java.text.DecimalFormat;

public class TKEmployee

{

//Variables
	Scanner entry = new Scanner(System.in);
	String Name;
	String LastName;
	String FirstName;
	int ID = 1;
	double hours;
	double pay;
	double LeftOvers;
	double exempt;
    double payAmt;
	double tempPay;
	double counterEmp = 0;
	double avgPay = 0;
	double tempPay4avg = 0;
	double overallPay = 0;
	final double OverTime = 40.0000;
	DecimalFormat formatter = new DecimalFormat("#0.00");
	DecimalFormat formatter2 = new DecimalFormat("#0");
// Set methods
	public void setName(String nam){Name = nam;}
	public void setCode(int Cod){ID = Cod;}
	public void setPay(double Pa){pay = Pa;}
	public void setHours(double Hour){hours = Hour;}
	public void setExempt(double exem){exempt = exem;}

//Strip name to first and last
public void stripName(String Name)
		{
			StringTokenizer strTokenizer = new StringTokenizer(Name, ",");
			LastName = strTokenizer.nextToken();
			FirstName = strTokenizer.nextToken();
		}



//GET methods
		public String getName(){return Name;}
		public int getCode(){return ID;}
		public double getHours(){return hours;}
		public String getLname(){return LastName;}
		public String getFname(){return FirstName;}
		public double getExempt(){return exempt;}


//CALCULATION FOR PAY
public double calcPay()
{
   if(hours <= OverTime)
   		{
   			return (hours * pay);
   		}
   		else if(hours >= OverTime);
   		{
   			if(exempt == 0)
   			{
   				LeftOvers = hours - OverTime;
   				return (((hours - LeftOvers) * pay) + ((1.5  * pay)*(LeftOvers)));
   			}
   			else
   			{return (hours * pay);}
		}
   }


//METHOD TO CALL calcPay()
public double getPay()
        {
               tempPay = calcPay();
               return tempPay;
        }



//PRINT CHECK:
	public void printCheck()
		{
            //NOT COMPLETED:

            stripName(Name);
            System.out.println("\n********************************************************************************" +
            getFname() + " " + getLname() + " " + "is paid $" + formatter.format(getPay()) + "\n\n********************************************************************************");

        }

   	public void counter()
   	{
	//here we count employees, paycheck average per employee and total pay for all,
	counterEmp++;
	overallPay = getPay() + overallPay;
	avgPay = (overallPay) / (counterEmp);
	}

//Get methods for Counter method
	public double getCounterEmp(){return counterEmp;}
	public double getOverallPay(){return overallPay;}
	public double getAvgPay(){return avgPay;}
//Displays report
	public void report()
	{
		say("The total number of employees are: " + formatter2.format(getCounterEmp()) + ".");
		say("$" + formatter.format(getOverallPay()) + " is the total amount of dollars towards payroll.");
		say("On average the employee recieves $" + formatter.format(getAvgPay()));
	}

	public static void say(String x){System.out.println(x);}


}



