import java.util.Scanner;
import java.text.*;

/**
 * CelsiusToFahrenheit will convert a Celsius temperature to an
 * equivalent Fahrenheit temperature.
 *
 * @author Solution, Nancy Harris
 * @version V1
 */
public class CelsiusToFahrenheit
{

   /**
    * Input the temperature in celsius and output the equivalent Fahrenheit 
    * temperature. Format the results with 1 decimal place.
    *
    * EXAMPLES - Provide 3 examples for testing
    *      Celcius    Fahrenheit
    * 1.   100         212
    * 2.   0           32    
    * 3.   30          86
    *
    * @param args command line arguments unused
    */
   public static void main (String[] args)
   {
      // declarations of constants followed by declarations of variables
      final double CONVERSION = 9.0/5.0;
      final double OFFSET = 32.0;
      
      Scanner keyboard;
      DecimalFormat formatter;
      DecimalFormat dfMoney;
      NumberFormat  money;
      
      double fahrenheit;
      double celcius;
      double amount;
    
      // perform initialization and get the required input
      keyboard = new Scanner(System.in);
      
      System.out.print("Enter the temperature in celcius: ");
      celcius = keyboard.nextDouble(); 
    
      // perform the conversion calculations
      fahrenheit = (celcius * CONVERSION) + OFFSET;
    
      // output the results
      System.out.printf("%.1f celcius = %.1f fahrenheit\n", celcius, fahrenheit);
      
      //----------------------DecimalFormat------------------------------------
      
      formatter = new DecimalFormat("0.0");
      System.out.println(formatter.format(celcius) + " celcius = " 
         + formatter.format(fahrenheit) + " fahrenheit");
         
      //-----------------------Other numbers-----------------------------------
      amount = 103.159456;
      System.out.println("The amount is: " + formatter.format(amount));
      
      //-----------------------Currency----------------------------------------
      System.out.printf("The amount in currency is: $%.2f\n", amount);
      
      dfMoney = new DecimalFormat("'$'0.00");
      System.out.println("The amount in currency is: " + dfMoney.format(amount));
      dfMoney = new DecimalFormat("0.00");
      System.out.println("The amount in currency is: $" + dfMoney.format(amount));
      
      money = NumberFormat.getCurrencyInstance();
      System.out.println("The amount in currency is: " + money.format(amount));
   }
}
