1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- public class ConversionTool {
-
-
- public static void main(String[] args){
-
- }
-
- public static float ErrorCheck(float unit){
- if(unit < 0){
- return (float)0.0;
- }
- else
- return unit;
- }
-
- public static float CentimetersToInches(float centimeters){
- centimeters = ErrorCheck(centimeters);
- return centimeters * (float)0.3937;
- }
-
- public static float InchesToCentimeters(float inches){
- inches = ErrorCheck(inches);
- return inches * (float)2.54;
- }
-
- public static float FeetToMeters(float feet){
- feet = ErrorCheck(feet);
- return feet * (float)0.3048;
- }
-
- public static float MetersToFeet(float meters){
- meters= ErrorCheck(meters);
- return meters * (float)3.28084;
- }
-
- public static float CelsiusToFahrenheit(float celsius){
- celsius = ErrorCheck(celsius);
- return (celsius * (float)9/5) + 32;
- }
-
- public static float FahrenheitToCelsius(float fahrenheit){
- fahrenheit = ErrorCheck(fahrenheit);
- return (fahrenheit - 32) * (float)5/9;
- }
-
- public static float MphToKph(float mph){
- mph = ErrorCheck(mph);
- return mph * (float)1.60934;
- }
-
- public static float KphToMph(float kph){
- kph = ErrorCheck(kph);
- return kph * (float)0.621371;
- }
- }
|