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