• Post Reply Bookmark Topic Watch Topic
  • New Topic

Can anybody explain on how to code this?  RSS feed

 
Prasad Lakshmi
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to code the following question. Got stuck up without using built in function. Can anybody explain?

Without using any built in date or time functions, write a function or method that accepts two mandatory arguments. The first argument is a string of the format "[H]H:MM {AM|PM}" and the second argument is an integer. Assume the integer is the number of minutes to add to the string. The return value of the function should be a string of the same format as the first argument. For example AddMinutes("9:35 AM", 10) would return "9:45 AM".

Help would be greatly appreciated.

Thanks
 
fred rosenberger
lowercase baba
Bartender
Posts: 12563
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
first thing:

Write a function that takes a string and an int as parameters, and prints them out.

Once you have that done, come back, and we'll work towards the next step.


Now, that may not seem like much help, but if I were writing this, that is exactly how far I would go before I compile and test. Actually, the first time I compile and test is after writing a main() method that does nothing but prints "I'm in main". I start EVERY SINGLE PROJECT this way.

What is important is that you never try and do too much at once. Always code the smallest amount you can before you recompile and test. just go one step at a time.
 
Luigi Plinge
Ranch Hand
Posts: 441
IntelliJ IDE Scala Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you don't know about it already, the modulus operator % will come in handy for this problem.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!