ConversionTool.java 1.3KB

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