Guyss can u help to my program??
this is the instructions:
DTR or Daily Time Record is a form which details each employee's total hours of work daily at the time of arrival and departure from office in the morning and in the afternoon.Employees must report on duty at exactly 08:00 AM in the morning until 12:00 NN. And in the afternoon, they must time-in at exactly 13:00 (1:00PM) until 17:00 (5:00PM).
Create a program that will read the employee’s DTR from the textfile named EmployeeDTR.txt. Extract the contents of the textfile and calculate the number of hours work for each employee. Display the employee’s number of hours worked in hours in minutes. Display also the date of the DTR. Use military time format. Disregard the late & early in or out.
Create the following methods that will help you solve the tasks:
1. A method to calculate the number of hours worked from time in until time out in hours and minutes.
2. A method to display your output
You can also create additional methods such as:
1. Methods used to read the contents of the text file
Here is the text from notepad:
Day:*Monday,*July 4, 2011
Jamie_SULLIVAN*2006-0031*Worker*2*08:00*12:00*13:00*17:00
John_SMITH*2001-0001*Manager*3*07:46*12:00*12:30*17:10
Tim_JONES*2010-0008*Worker*1*08:01*11:55*13:00*16:55
Here is a sample output:
----------------------------------------------------------------
EMPLOYEE’s Daily Time Record
Day: Monday, July 4, 2011
-----------------------------------------------------------------
EmployeeID : 2006-0031
Lastname : SULLIVAN
Firstname : Jamie
Position : Worker
Rank : 2
Morning
IN : 08:00
OUT : 12:00
Afternoon
IN : 13:00
OUT : 17:00
Total hours worked: 8 hrs and 0 mins
-----------------------------------------------------------------
This is my work guys.. plss hel mee
import java.io.*;
import java.util.*;
public class EmployeeDTR{
public static void main(String args[])
{
String Filename = "EmployeeDTR.txt";
try
{
FileReader fr = new FileReader(Filename);
BufferedReader br = new BufferedReader(fr);
String list = br.readLine();
System.out.println("Employer's Daily Time Record");
date(list);
while(list !=null)
{
list = br.readLine();
EmployeeProfile(list);
}
fr.close();
}
catch(IOException e)
{
System.out.println("Problem Reading File: " + Filename);
}
//---------------------get the date---------------------------------
public static void date(String list)
{
StringTokenizer st = new StringTokenizer(list,"*");
while(st.hasMoreTokens())
{
System.out.println(st.nextToken() + " ");
}
System.out.println("\n--------");
}
// -----------------get the employee profile-------------------------
public static void EmployeeProfile(String list)
{
String EmployeeID,FirstName,LastName,position,rank,Am_In, Am_Out,Pm_In,Pm_Out;
StringTokenizer st = new StringTokenizer(list,"*_");
EmployeeID = st.nextToken();
FirstName = st.nextToken();
LastName = st.nextToken();
position = st.nextToken();
rank = st.nextToken();
Am_In = st.nextToken(); //08:00
Am_Out = st.nextToken();//12:00
Pm_In = st.nextToken();
Pm_Out = st.nextToken();
System.out.println("Employee ID: " + EmployeeID);
System.out.println("Last Name : " + lastName);
System.out.println("First Name : " + FirstName);
System.out.println("Position : " + position);
System.out.println("Rank : " + rank);
System.out.println("\nMorning");
System.out.println("\t IN: " + AM_In);
System.out.println("\tOUT: " + AM_Out);
System.out.println("\nAfternoon");
System.out.println("\t IN: " + PM_In);
System.out.println("\tOUT: " + PM_Out);
daily_hours_work( AM_In,AM_Out,PM_In,PM_Out);
System.out.println("-----------------------------------------------------------------------------");
}
//-------------------------------total hours worked---------------------------
public static void daily_hours_work(String AM_In,AM_Out,PM_In,PM_Out)
{
StringTokenizer HoursIn_amToken = new StringTokenizer(AM_In,":");
int Hours_AM_In = Integer.parseInt(HoursIn_amToken.nextToken());
int Minutes_AM_In = Integer.parseInt(HoursIn_amToken.nextToken());
StringTokenizer MinutesOut_amToken = new StringTokenizer(AM_Out,":");
int Hours_AM_Out = Integer.parseInt(MinutesOut_amToken.nextToken());
int Minutes_AM_Out = Integer.parseInt(MinutesOut_amToken.nextToken());
StringTokenizer HoursIn_pmToken = new StringTokenizer(PM_In,":");
int Hours_PM_in = Integer.parseInt(HoursIn_pmToken.nextToken());
int Minutes_PM_in = Integer.parseInt(HoursIn_pmToken.nextToken());
StringTokenizer MinutesIn_pmToken = new StringTokenizer(PM_Out,":");
int Hours_PM_out = Integer.parseInt(HoursIn_pmToken.nextToken());
int Minutes_PM_out = Integer.parseInt(HoursIn_pmToken.nextToken());
int Total_AM_Hours = Hours_AM_Out - Hours_AM_In; //calculate the subtotal morning hrs
int total_AM_Minutes = Minutes_AM_Out + Minutes_AM_In; //calculate the subtotal morning mins
int Total_PM_Hours = Hours_PM_out - Hours_PM_in; //calculate the subtotal afternoon hrs
int Total_PM_Minutes = Minutes_PM_out + Minutes_PM_in; //calculate the subtotal afternoon mins
int TotalHours = Total_AM_Hours + Total_PM_Hours; //calculate the total
int TotalMinutes = total_AM_Minutes + Total_PM_Minutes;
System.out.println("nTotal hours worked:" + TotalHours + " hrs and " + TotalMinutes + " mins");
System.out.println("-----------------------------------------------------------------------------");
}
}
}