public static int convertToSeconds(int hour) { int sec = hour / 3600; return sec; } public static void main(String[] args) { System.out.println ((convertToSeconds(34))); System.out.println ((convertToSeconds(15))); } 
  • The code as it turned out to be crooked. Where to read the certificate? - hellog888
  • Thanks for editing the code :) - hellog888
  • formatting help: ru.stackoverflow.com/editing-help - Sublihim

1 answer 1

I'm sure i mean

 int sec = hour * 3600; ^^^ 

Otherwise, this expression hour / 3600 will always be 0 for the given arguments, since integer arithmetic takes place.

  • Thank you: D It was stupid to ask such questions. - hellog888
  • @HelloGoogle No big deal. It happens. :) - Vlad from Moscow
  • @HelloGoogle, if the answer satisfies completely, mark it as correct - Sublihim