ConversionTool.java 1.2KB

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