1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- public class ConversionTool {
-
- public static void main(String[] args){
- }
-
- public static float CentimetersToInches(float centimeters){
- float inch = centimeters * (float) 0.393701;
- if (centimeters < 0){
- return 0;
- } else {
- return inch;
- }
-
- }
-
- public static float InchesToCentimeters(float inches){
- float centimeters = inches * (float) 2.54;
- if (inches < 0) {
- return 0;
- } else {
- return centimeters;
- }
-
- }
-
- public static float FeetToMeters(float feet){
- float meters = feet * (float) 0.304800164592;
- if (meters < 0){
- return 0;
- }
- return meters;
- }
-
- public static float MetersToFeet(float meters){
- float feet = meters * (float) 3.28084166666666599;
- if (meters < 0) {
- return 0;
- }
- return feet;
- }
-
- public static float CelsiusToFahrenheit(float celsius){
- float fahrenheit =((celsius)* (float)1.8) + (float)32 ;
- if (fahrenheit < 0 ){
- return 0;
- }
- return fahrenheit; //this is the problem
- }
-
- public static float FahrenheitToCelsius(float fahrenheit){
- float celsius = (fahrenheit - 32)/(float)1.8;
- if (fahrenheit < 0) {
- return 0;
- }
- return celsius; //this is the problem too
- }
-
- public static float MphToKph(float mph){
- float kph = mph * (float) 1.60934;
- if (mph < 0) {
- return 0;
- }
- return kph;
- }
-
- public static float KphToMph(float kph){
- float mph = kph *(float) 0.621371;
- if (kph < 0){
- return 0;
- }
- return mph;
- }
- }
|