so Im trying to make a program that can convert s from input into h, m and s. my code so far looks like this:
import java.util.Scanner;
class q2_5{
public static void main(String args[]){
Scanner input = new Scanner(System.in);
int s=0;//seconds
int m=0;//minutes
int h=0;//hour
System.out.println("how many seconds?");
s=input.nextInt();
if(s >= 60){
m=s/60;
} if(m>=60){
h=m/60;
}
System.out.println(s + "s = " + h + " h " + m + " m " + s + "s ");
}
}
ok so I had to initialize s,m,h to 0 cuz if not I was getting problems in the if statement, so I just put it to 0, since I can change it later :) ok. so the problem with this program right now is that if I type in 3603 I get this output: 3603s = 1 h 60 m 3603s, if I type in 3600 I get this: 3600s = 1 h 60 m 3600s, but the output should have been 3603s = 1h 0m 3s and 3600s = 1h 0m 0s respectively. any tips/advice/solutions on how to solve this problem? :D thanks in advance!