Trying to create a program that converts between a given unit and either ft mm m cm in or mi. user enter the starting unit and its value and the unit to which they want to convert. I am new to java and cannot seem to get this to work properly. code is as follows right now, although i think the problem may be in the tester. I am supposed to use two objects and convert between meters and the given value.

public class UnitConverter
*Constructs a class that converts measurements to different units
public UnitConverter()
unitTo= null;
unitFrom= null;
*Constructs a class that converts measurements to different units
*@param inUnitFrom the unit to convert
public UnitConverter(String inUnitFrom, String inUnitTo, double inVal)
unitFrom = inUnitFrom;
unitTo= inUnitTo;
inVal = val;
public double getConversion()
double finalVal=0;
double valInMeters=0;
if (unitFrom.equalsIgnoreCase("m"))
valInMeters = val;
else if (unitFrom.equalsIgnoreCase("ft"))
valInMeters = val*M_IN_FT;
else if (unitFrom.equalsIgnoreCase("mm"))
valInMeters = val*M_IN_MM;
else if (unitFrom.equalsIgnoreCase("cm"))
valInMeters = val*M_IN_CM;
else if (unitFrom.equalsIgnoreCase("in"))
valInMeters = val*M_IN_IN;
else if (unitFrom.equalsIgnoreCase("mi"))
valInMeters = val*M_IN_MI;
else if (unitFrom.equalsIgnoreCase("km"))
valInMeters = val*M_IN_KM;
if (unitTo.equalsIgnoreCase("m"))
finalVal = valInMeters;
else if (unitTo.equalsIgnoreCase("ft"))
finalVal = valInMeters/ M_IN_FT;
else if (unitTo.equalsIgnoreCase("mm"))
finalVal = valInMeters/ M_IN_MM;
else if (unitTo.equalsIgnoreCase("cm"))
finalVal = valInMeters/ M_IN_CM;
else if (unitTo.equalsIgnoreCase("in"))
finalVal = valInMeters/ M_IN_IN;
else if (unitTo.equalsIgnoreCase("mi"))
finalVal = valInMeters/ M_IN_MI;
else if (unitTo.equalsIgnoreCase("km"))
finalVal = valInMeters/ M_IN_KM;
return finalVal;
private String unitTo;
private String unitFrom;
private double val;

public static final double M_IN_FT = .3048;
public static final double M_IN_MM = .001;
public static final double M_IN_CM = .01;
public static final double M_IN_IN = .0254;
public static final double M_IN_MI = 1609.344;
public static final double M_IN_KM = 1000;


And Tester:
//Alex Romano
//5.14 UnitConverter tester

import java.util.Scanner;
public class UnitConverterTester23
public static void main (String[]args)
Scanner scan = new Scanner (;
System.out.println("Converting from:");
String from =;
System.out.println("Converting to:");
String to =;
System.out.println("Enter the value of the measurement");
double val= scan.nextInt();
UnitConverter conv1 = new UnitConverter(from, to, val);
UnitConverter conv2 = new UnitConverter (to, from, val);
System.out.println(val+ " " +from+ " = " +conv1.getConversion()+ " " +to);