Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-13-2008, 03:30 AM
Member
 
Join Date: Oct 2008
Posts: 2
yadster101 is on a distinguished road
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
Sponsored Links
  #2 (permalink)  
Old 10-13-2008, 04:13 AM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Heredia, Costa Rica
Posts: 2,223
Norm is on a distinguished road
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 04:15 AM.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 10-13-2008, 07:01 AM
CJSLMAN's Avatar
Senior Member
 
Join Date: Oct 2008
Location: Guadalajara, Mexico
Posts: 201
CJSLMAN is on a distinguished road
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
Sponsored Links
Reply


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

vB 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 04:39 AM
Problem here guys: Set location or setBounds themburu New To Java 3 06-03-2008 09:19 PM
Is my Pseudocode correct? Clemenza1983 New To Java 0 01-29-2008 06:07 AM
To correct forum Jman Introductions 3 01-18-2008 04:33 AM
Correct Number formatting paul New To Java 1 08-07-2007 06:59 AM


All times are GMT +3. The time now is 10:38 AM.


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