Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class SpeedConverter {
- public static long toMilesPerHour(double kilometersPerHour){
- if(kilometersPerHour < 0){
- return -1;
- }
- else {
- return Math.round(kilometersPerHour / 1.609);
- }
- }
- public static void printConversion(double kilometersPerHour) {
- int miles = (int) Math.round(kilometersPerHour / 1.609);
- if (kilometersPerHour < 0) {
- System.out.println("Invalid Value");
- } else {
- System.out.println(kilometersPerHour + " km/h " + "= " + miles + " mi/h");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement