0
System.out.println("Extra credit\nRe-enter number of seconds:");          
  int j = input.nextInt();
  int i =(j/60);
  int k = (j%60);                         
  System.out.println(j+" seconds is " +i+" minutes and "+k+" seconds.");

Hi when i key in 30 for j the correct answer should be 30seconds is 0minutes and 0seconds.
However my above code gives me 30seconds is 0minutes and 30seconds.
What am i doing wrong?

3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by zeroliken
0

Wouldn't the correct answer be "30seconds is 0minutes and 30seconds.", in which case your code is working perfect.

Perhaps you can clarify why 30 != 30?

0

It's not really a bug, the modulus is doing whats its suppose to do

are you trying to make the program display 0 when 30 or a similar case is entered?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.