ConversionTool.java 960B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. public class ConversionTool {
  2. public static void main(String[] args){
  3. }
  4. public static float CentimetersToInches(float centimeters){
  5. return centimeters < 0 ? 0 : centimeters * 0.393701f;
  6. }
  7. public static float InchesToCentimeters(float inches){
  8. return inches < 0 ? 0 : inches * 2.54f;
  9. }
  10. public static float FeetToMeters(float feet){
  11. return feet < 0 ? 0 : feet * 0.3048f;
  12. }
  13. public static float MetersToFeet(float meters){
  14. return meters < 0 ? 0 : meters * 3.28084f;
  15. }
  16. public static float CelsiusToFahrenheit(float celsius){
  17. return (celsius * 1.8f) + 32;
  18. }
  19. public static float FahrenheitToCelsius(float fahrenheit){
  20. return (fahrenheit - 32) / 1.8f;
  21. }
  22. public static float MphToKph(float mph){
  23. return mph < 0 ? 0 : mph * 1.60934f;
  24. }
  25. public static float KphToMph(float kph){
  26. return kph < 0 ? 0 : kph * 0.62137f;
  27. }
  28. }