ConversionTool.java 1.4KB

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