ConversionTool.java 1.1KB

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