Created
August 1, 2019 09:38
-
-
Save 0ryant/c48ce87a57e04c2462e45c78b183813a to your computer and use it in GitHub Desktop.
Java - Coding Challenge 1 - Speed Converter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SpeedConverter { | |
public static long toMilesPerHour(double kilometersPerHour){ | |
if (kilometersPerHour <0) { | |
return -1; | |
} | |
return Math.round(kilometersPerHour/1.609); | |
} | |
public static void printConversion (double kilometersPerHour) { | |
if (kilometersPerHour <0) { | |
System.out.println("Invalid Value"); | |
} else { | |
long mPH = toMilesPerHour(kilometersPerHour); | |
System.out.println(kilometersPerHour + " km/h = " + mPH + " mi/h"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
yes first one is working now