I was wondering if anyone has ever had to do a program like this. I have to read a number in thru a dialog box and convert an amount of seconds into hours, minutes, and seconds. Its supposed to have a messagebox pop up that tells the time, then another dialog should come up that asks if a user would like to repeat the action. here is the code i have so far. Any help or suggestions would be greatly appreciated. Thank you.
Here is ur code with some modifications to it. What was the parameter for? You need to use the time given by the user through the input box. And always comment your code to exlpain to other users of the code what your thoughts are.
import javax.swing.*;
publicclass Program1
{
publicvoid calcHMS()
{
char repeat;
do
{
int input = new Integer(JOptionPane.showInputDialog("Enter Seconds ")).intValue();
int hours, minutes, seconds;
hours = input / 3600;
input = input - (hours * 3600);
minutes = input / 60;
input = input - (minutes * 60);
seconds = input;
JOptionPane.showMessageDialog(null, "The time is "+(hours + " hour(s) " + minutes + " minute(s) " + seconds + " second(s)"));
repeat = (JOptionPane.showInputDialog("Enter 'Y' to repeat, or 'N' to quit")).charAt(0);
}
while (repeat == 'Y' || repeat =='y');
System.exit(0);
}
publicstaticvoid main(String[] args)
{
Program1 prog = new Program1();
prog.calcHMS();
}
}