import electric.registry.Registry;

public class TempClient
{
   public static void main(String[] args) throws Exception
   {
      if(args.length<2)
      {
         System.out.println("You must give temp and scale.");
         System.out.println("For instance:  21 F");
         System.exit(-1);
      }
      
      if(!(args[1].equals("C") || args[1].equals("F")))
      {
         System.out.println("Incorrect Temperature Scale.");
         System.out.println(" You must specify either 'F' or 'C'");
         System.exit(-1);
      }
      ITempConverter tempconverter = TempConverterHelper.bind();
      String temp_as_string = args[0];
      double starttemp = (new Double(temp_as_string)).doubleValue();
      double endtemp;
      if(args[1].equals("F"))
      {
         endtemp = tempconverter.FtoC(starttemp);
         System.out.println("The equivalent temperature is: "+endtemp
            +" degrees C");
      }
      else if(args[1].equals("C"))
      {
         endtemp = tempconverter.CtoF(starttemp);
         System.out.println("The equivalent temperature is: "+endtemp
            +" degrees F");
      }
   }
}
