12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- public class ConversionTool {
-
- private static final float CENT_TO_INCH = (float) 2.54;
-
- public static void main(String[] args){}
-
- public static float CentimetersToInches(float centimeters){
- float inches = centimeters / CENT_TO_INCH;
- return ifNegGetZero(inches);
- }
-
- public static float InchesToCentimeters(float inches){
- float centimeters = inches * CENT_TO_INCH;
- return ifNegGetZero(centimeters);
- }
-
- public static float FeetToMeters(float feet){
- float meters = feet / (float)3.28;
- return ifNegGetZero(meters);
- }
-
- public static float MetersToFeet(float meters){
- float feet = meters * (float)3.2808;
- return ifNegGetZero(feet);
- }
-
- public static float CelsiusToFahrenheit(float celsius){
- float fahr = celsius * (float)(1.8) + (float)(32);
- return fahr;
- }
-
- public static float FahrenheitToCelsius(float fahrenheit){
- float cels = (fahrenheit - (float)(32)) / (float) (1.8);
- return cels;
- }
-
- public static float MphToKph(float mph){
- float kph = mph * (float)(1.60934);
- return ifNegGetZero(kph);
- }
-
- public static float KphToMph(float kph){
- float mph = kph / (float)(1.60934);
- return ifNegGetZero(mph);
- }
-
- public static float ifNegGetZero(float number){
- if (number >=0) {
- return number;
- } else {
- return 0;
- }
- }
- }
|