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