Results 1 to 3 of 3
- 10-13-2008, 02:30 AM #1Member
- Join Date
- Oct 2008
- Rep Power
New to java just wondering if you guys could tell me if i did this problem correct?
So the question is:
curHour and curMin represent the current time, and depHour, depMin
represent the departure time of a bus. Suppose all these variables are
initialized with some values; both times are between 1 p.m. and 11 p.m of the
same day. Fill in the blanks in the following statements that display the
remaining waiting time in hours and minutes:
int ____________ =
System.out.println( ______________________________ +
" hours and " + ______________________________ +
My answer is:
int Waiting_Time= (depHour + depMin) - (curHour + curMin);
System.out.println("Waiting_Time=" + "hours and" + ___________+ "minutes.");
Im not sure how i would get the minutes here without declaring them before?
- 10-13-2008, 03:13 AM #2how i would get the minutes here without declaring them before
If you know the current time and the departure time, do the arithmetic to compute the hours and minutes between them. Hours are based 24 and minutes are based 60. Ie when incrementing minutes, roll over at 60 minutes to the next hour.
How is this a java programming question?
Last edited by Norm; 10-13-2008 at 03:15 AM.
- 10-13-2008, 06:01 AM #3
blanks vs variables
I think that the blanks in the Sytem.out.println should contain the combination of variables to indicate the waiting time; therefore the first blank should be the variables to indicate the hours (not "Waiting Time =") and the second blank the minutes (taking into account what Norm stated, the 60 min rollover)Chris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
- By abhinav_jain09 in forum Java AppletsReplies: 4Last Post: 09-19-2008, 03:39 AM
- By themburu in forum New To JavaReplies: 3Last Post: 06-03-2008, 08:19 PM
- By Clemenza1983 in forum New To JavaReplies: 0Last Post: 01-29-2008, 05:07 AM
- By Jman in forum IntroductionsReplies: 3Last Post: 01-18-2008, 03:33 AM
- By paul in forum New To JavaReplies: 1Last Post: 08-07-2007, 05:59 AM