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?

Recommended Answers

All 2 Replies

Member Avatar

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?

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?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.