Hello everyone,
I am pretty new to java and i have an assignment that to write the code for clock in and clock out for employee .Down here is my code, and now i am stuck with the while loop to print out the name, like if Bob work on Monday with several work session, it should display with the name Bob and Monday and the total hours on that day. Please help me.
import java.util.Scanner;
public class TimeClock
{
public static void main(String [] args) {
System.out.println("Employee Work Report :");
System.out.println("Person "+ " " + "Day "+ " " + "Hours "+ " " +" WeekRegular "+ " " + "WeekOVT" );
String name;
String day;
String timein;
String timeout;
// read in by Scanner
Scanner input = new Scanner(System.in);
name = input.next();
day = input.next();
timein = input.next();
timeout = input.next();
while(!input.equals("END")){
String currentName = name;
if (currentName.equals(name)){
System.out.println(currentName);
}
else
currentName = name;
}
}
public static int hour(String x)
{
int y = x.indexOf(":");
String hour = x.substring(0,y);
int hour1= Integer.valueOf(hour);
return hour1;
}
public static int minute(String x)
{
int y = x.indexOf(":");
String minute = x.substring(y+1,y+3);
int minute1 = Integer.valueOf(minute);
return minute1;
}
public static float thediff(int hour, int minute, int hour1, int minute1)
{
float diff = hour1 - hour;
float theminute = minute1 - minute;
float theminute1 = theminute / 60;
if(theminute1 < 0){
theminute1= (-1)*theminute1;
}
return (diff + theminute1);
}
}