0

My code has me stumped, My method is right...I think but the output begs to differ. Basically this code is supposed to convert seconds to minutes but the output is somewhat off..here's what I have don so far.

String input = JOptionPane.showInputDialog(null, "Enter a value for seconds (positive whole number): ");



int second = Integer.parseInt(input);

int minutes = second/60; // number of minutes

int seconds = second/60; // number of seconds


JOptionPane.showMessageDialog(null, "Numbber of Seconds is " + second + " is converted to: "
         + minutes + " minutes and " + seconds + " seconds.");

Any pointers / tips would be greatly appreciated :)

2
Contributors
1
Reply
20
Views
3 Years
Discussion Span
Last Post by oussama_1
2

for seconds you need the remainder:

int seconds = second%60;
Votes + Comments
Ah jeez I'm slipping, I knew it was only something small it was missing :) Thank you
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.