Public paste
code
By: amos | Date: Nov 13 2008 09:42 | Format: None | Expires: never | Size: 979 B | Hits: 629

  1. public class Travel
  2. {
  3.  
  4.  
  5.    public static void main(String[] argv)
  6.    {
  7.        
  8.        double distance;
  9.        double time;
  10.        double speed = 85;
  11.        int remain;
  12.        
  13.        
  14.        System.out.println("Please enter the amount of kilometres");
  15.        
  16.        distance = UserInput.readDouble();
  17.        
  18.        time = distance / speed;
  19.        
  20.        System.out.println("The time that it would take to travel " + distance + " is " + (int)(time * 3600) + " seconds");
  21.        
  22.        System.out.println("The time that it would take to travel is " + (int)time + " hours");
  23.        
  24.        remain = (int)(time * 3600);
  25.        
  26.        remain = remain % 3600;
  27.        
  28.        System.out.println("The remainder is " + remain);
  29.        
  30.        System.out.println("The remaining number of seconds is " + remain % 60);
  31.        
  32.        System.out.println("The remaining number of minutes is " + remain / 60);
  33.      
  34.    } // end of main
  35.  
  36. } // end class