/* Raffaella Lanzarotti, Sabrina Gaito Data Ultima Modifica: 25 Ottobre 2005
/* Questo programma converte gradi Celsius in Kelvin o Farenheit e viceversa. */

#include <stdio.h>
#include <conio.h>
#define CONVERSIONE_CK -273.15
#define CONVERSIONE_KC 273.15
#define CONVERSIONE_CF 1.8

int main(void)
{
   double   celsius, kelvin, fahrenheit, temperatura;
   char     c1, c2;
   printf ("\n Scegli che conversione vuoi tra \n CK   da Celsius a Kelvin \n KC   da Kelvin a Celsius \n CF   da Celsius a Fahrenheit \n FC   da Fahrenheit a Celsius\n");
   scanf ("%c%c",&c1,&c2);
   printf ("Immetti temperatura \n");
   scanf ("%lf", &temperatura);
   if (c1=='C' && c2=='K')
      {kelvin = temperatura + CONVERSIONE_CK;
       printf ("%lf Celsius equivalgono a %lf Kelvin",temperatura, kelvin);
       }
   else if (c1=='K' && c2=='C')
      {celsius = temperatura + CONVERSIONE_KC;
       printf ("%lf Kelvin equivalgono a %lf Celsius", temperatura, celsius);
      }
   else if (c1=='C' && c2=='F')
      {fahrenheit = CONVERSIONE_CF * temperatura + 32;
       printf ("%lf Celsius equivalgono a %lf Fahrenheit", temperatura, fahrenheit);
      }        
   else if (c1=='F' && c2=='C')
      {celsius =  (fahrenheit - 32) /CONVERSIONE_CF ;
       printf ("%lf Fahrenheit equivalgono a %lf Celsius", temperatura, celsius);
      }        
   getch();
   return 0;
}

