Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-13-2008, 01:30 AM
Member
 
Join Date: Oct 2008
Posts: 2
Rep Power: 0
yadster101 is on a distinguished road
Default 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 " + ______________________________ +
" minutes.");


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?
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 10-13-2008, 02:13 AM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Heredia, Costa Rica
Posts: 2,225
Rep Power: 4
Norm is on a distinguished road
Default
Quote:
how i would get the minutes here without declaring them before
Not sure what you are asking, unless its how to do arithmetic.
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 02:15 AM.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 10-13-2008, 05:01 AM
CJSLMAN's Avatar
Moderator
 
Join Date: Oct 2008
Location: Mexico
Posts: 1,149
Rep Power: 2
CJSLMAN is on a distinguished road
Default 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.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
guss which is correct answer abhinav_jain09 Java Applets 4 09-19-2008 02:39 AM
Problem here guys: Set location or setBounds themburu New To Java 3 06-03-2008 07:19 PM
Is my Pseudocode correct? Clemenza1983 New To Java 0 01-29-2008 04:07 AM
To correct forum Jman Introductions 3 01-18-2008 02:33 AM
Correct Number formatting paul New To Java 1 08-07-2007 04:59 AM


All times are GMT +2. The time now is 06:04 AM.



VBulletin, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org