Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Exam study review question

  1. #1
    Junior Member
    Join Date
    Oct 2012
    Posts
    15
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Exam study review question

    Time is given as a 4 digit string. First 2 digits represent hour, the last 2 represent minitute.
    Thus 935 is 9 hours 35 minutes (9:35am), 1454 is 14 hours 54 minutes (2:54pm).
    • Write a method that prints time in hours and minutes (0-23 hours) without using decision logic.
    • Expend the previous method to print time with am/pm distinction-allowed to use if/else to differentiate between am and pm.


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Exam study review question

    What have you done? Where are you stuck?

  3. #3
    Junior Member
    Join Date
    Oct 2012
    Posts
    15
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: Exam study review question

    I have no idea how to start It says 4 digit string so I thought about parse to convert to int but I really have no idea how to begin.... Any help or guidance would be really appreciated thanks

  4. #4
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Exam study review question

    Break the problem down. How would you do this by hand? Write out the steps on paper if the need be. For instance, you have a four digit string, and you need an algorithm to get the first and last two digits. Then think about how you can implement those steps using code - see the API for the String and Integer classes, which might be helpful here.

    I recommend reading the following article: http://www.javaprogrammingforums.com...e-posting.html

Similar Threads

  1. Please help me with my Case Study
    By dalexquisite in forum Object Oriented Programming
    Replies: 2
    Last Post: September 26th, 2012, 11:58 PM
  2. Review Mobile
    By workmo6 in forum Java ME (Mobile Edition)
    Replies: 1
    Last Post: June 19th, 2012, 03:18 PM
  3. Java exam paper
    By javanoobie in forum Java Theory & Questions
    Replies: 0
    Last Post: May 3rd, 2012, 12:24 PM
  4. Kindly Review My Code :-) Thanks in advance
    By bhuppi in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 27th, 2012, 10:10 AM
  5. [SOLVED] Exercise for study course help?
    By SweetyStacey in forum Object Oriented Programming
    Replies: 12
    Last Post: April 25th, 2010, 02:01 PM