java - How do I calculate total hours in a GUI-based program? -
i creating simple gui-based time card. have implementation (given friend) made in non-gui program.
system.out.print("enter time-in: "); string strtimein = input.next(); string timeinarr[] = strtimein.split(":"); double dbltimeinhr = double.parsedouble(timeinarr[0]); double dbltimeinmin = double.parsedouble(timeinarr[1]); double dbltotaltimein = dbltimeinhr + (dbltimeinmin/60); system.out.print("enter time-out: "); string strtimeout = input.next(); string timeoutarr[] = strtimeout.split(":"); double dbltimeouthr = double.parsedouble(timeoutarr[0]); double dbltimeoutmin = double.parsedouble(timeoutarr[1]); double dbltotaltimeout = dbltimeouthr + (dbltimeoutmin/60); totalhrs = totalhrs + (dbltotaltimeout - dbltotaltimein);
it works actually. couldn't work when apply on gui-based program. have 2 jtextfield, user input time-in , time-out. , jtextfield, total1, seteditable(false) display total hours.
total1.addactionlistener(new actionlistener() { public void actionperformed(actionevent e) { string timein = tin1.gettext(); string timeinarr[] = strtimein.split(":"); double dbltimeinhr = double.parsedouble(timeinarr[0]); double dbltimeinmin = double.parsedouble(timeinarr[1]); double dbltotaltimein = dbltimeinhr + (dbltimeinmin/60); string timeout = tout1.gettext(); string timeoutarr[] = strtimeout.split(":"); double dbltimeouthr = double.parsedouble(timeoutarr[0]); double dbltimeoutmin = double.parsedouble(timeoutarr[1]); double dbltotaltimeout = dbltimeouthr + (dbltimeoutmin/60); totalhours = totalhours + (dbltotaltimeout - dbltotaltimein); tal1.settext(totalhours); } });
the error i'm getting "cannot find symbol" points to:
string timeinarr[] = strtimein.split(":");
and
string timeoutarr[] = strtimeout.split(":");
i know there's wrong code, couldn't figure out. please help.
strtimein
not declared anywhere, meant utilize timein
.
java
No comments:
Post a Comment