Results 1 to 3 of 3
  1. #1
    yadster101 is offline Member
    Join Date
    Oct 2008
    Rep Power

    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?

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Eastern Florida
    Rep Power


    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.

  3. #3
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Rep Power

    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.

Similar Threads

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts