0
package timeConversion;
import java.util.Scanner;

public class TimeConversion {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.println("Please enter the time in minutes: ");
        int time = input.nextInt();//time in minutes
        int hour = time / 60;// hour 
        int minute = time % 60; //minutes
        System.out.print("The time is: " + hour + ":" + minute);


    }

}

So I'm having trouble with values in the minute spot being less than 10. for example, when you time in 184 minutes, the output is 3:4, but i would like it to read 3:04. how could I go about doing this ?

Chase
  • 59
  • 1
  • 8

1 Answers1

0

Just a quick hack

if(minute < 10)
    System.out.println("The time is: " + hour + ":0" + minute);
else
    System.out.print("The time is: " + hour + ":" + minute);
Samuel Lin
  • 99
  • 8