-5
 import java.util.Scanner;

   public class TimeConversion{ 
   public static void main(String[] args) {
    int min= 0;  
    int hours = min / 60; 
        int minutes = min % 60;
    Scanner keyboard = new Scanner(System.in);
    System.out.print("Enter the time in minutes:");
    minutes = keyboard.nextInt();
    System.out.print("The time is: ");

    System.out.printf("%d:%02d", hours, minutes);


}

}

我如何完成代码?

4

2 回答 2

3

尝试这个

    int hours = min / 60; 
    int minutes = min % 60;
    System.out.print("The hours is "+hours+" and minutes is "+minutes);

编辑

 import java.util.Scanner;

   public class TimeConversion{ 
   public static void main(String[] args) {
   int minutes = min % 60;
   Scanner keyboard = new Scanner(System.in);
   System.out.print("Enter the time in minutes:");
   minutes = keyboard.nextInt();
   int hours = minutes / 60; 
   int minutes1 = minutes % 60;
   System.out.print("The hours is "+hours+" and minutes is "+minutes1);
    }
   }
于 2013-09-30T02:42:32.147 回答
-1
min = keyboard.nextInt();    

int hours = Integer.parseInt(Math.floor(min/60));
int minutes = min % 60;
System.out.print("The time is " + hours + ":" + minutes);
于 2013-09-30T02:55:08.467 回答