newbie with some questions =]
Hello all! I'm very new to Java and am just getting used to it.
First off, how long does it usually take/did it take you to get certified? .*)
Secondly, I have this code that converts seconds to hours, minutes, seconds.
I have two problems I'm hoping one of you JavaGods can help me out with:
1.) How would you format it so the output is on one line ie., 23:05:10
2.) How do you change the data type, if that's what it is so I can input a lot of seconds. I'm not quite sure how many but if I input too many integers I get this error message:
java.util.InputMismatchException: For input string: "34543543535"
at java.util.Scanner.nextInt(Scanner.java:2097)
at java.util.Scanner.nextInt(Scanner.java:2050)
at MakeTime.main(MakeTime.java:17)
java.util.InputMismatchException: For input string: "34534545345"
at java.util.Scanner.nextInt(Scanner.java:2097)
at java.util.Scanner.nextInt(Scanner.java:2050)
at MakeTime.main(MakeTime.java:17)
or I'll get:
InputMismatchException:
For input string: "34534545345" (in java.util.Scanner)
__
Here's my code:
import java.util.*;
publicclass MakeTime
{
static Scanner console =new Scanner(System.in);
staticfinalint HOURS = 3600;
staticfinalint MINUTES = 60;
publicstaticvoid main(String[] args)
{
int time;
System.out.print("Enter the time in seconds: ");
System.out.flush();
time = console.nextInt();
System.out.println();
System.out.println("Hours: " + time / HOURS);
time = time % HOURS;
System.out.println("Minutes: " + time / MINUTES);
time = time % MINUTES;
System.out.println ("Seconds: " + time);
}
}
Perhaps, I should've put this thread in the "New to Java" forum. =]

