There is a typo in your code
see where you have
Code:
String time = convert(milliseconds);
that should be
Code:
String time = convertMillis(milliseconds);
because thats the name of the function you created
and why do you have the variable seconds,minutes,hours declared at the start ? you are not using them.
here I did some clean up on your code
Code:
import java.util.Scanner;
public class Converter {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
long milliseconds = 0;
System.out.print("Enter an amount in miliseconds:");
milliseconds = input.nextLong();
String time = convertMillis(milliseconds);
System.out.print(time);
}
public static String convertMillis(long milliseconds){
long seconds, minutes, hours;
seconds = (milliseconds / 1000) % 60 ;
minutes = ((milliseconds / (1000*60)) % 60);
hours =((milliseconds / (1000*60*60)) % 24);
return("Your conversion is: " + hours + "h:" + minutes + "m:" + seconds +"s");
}
}
hope this helps
Bookmarks