- public class Travel
- {
- public static void main(String[] argv)
- {
- double distance;
- double time;
- double speed = 85;
- int remain;
- System.out.println("Please enter the amount of kilometres");
- distance = UserInput.readDouble();
- time = distance / speed;
- System.out.println("The time that it would take to travel " + distance + " is " + (int)(time * 3600) + " seconds");
- System.out.println("The time that it would take to travel is " + (int)time + " hours");
- remain = (int)(time * 3600);
- remain = remain % 3600;
- System.out.println("The remainder is " + remain);
- System.out.println("The remaining number of seconds is " + remain % 60);
- System.out.println("The remaining number of minutes is " + remain / 60);
- } // end of main
- } // end class
code
By: amos | Date: Nov 13 2008 09:42 | Format: None | Expires: never | Size: 979 B | Hits: 1061
Latest pastes
16 hours ago
2 days ago
3 days ago
6 days ago
7 days ago