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.
Re: Exam study review question
What have you done? Where are you stuck?
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
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