/* 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;
   int      scelta;

   printf ("\n Scegli che conversione vuoi tra \n 1 da Celsius a Kelvin \n 2   da Kelvin a Celsius \n 3   da Celsius a Fahrenheit \n 4   da Fahrenheit a Celsius\n");
   scanf ("%d",&scelta);
   printf ("Immetti temperatura \n");
   scanf ("%lf", &temperatura);
   switch (scelta) {
          case 1:
               {kelvin = temperatura + CONVERSIONE_CK;
                printf ("%lf Celsius equivalgono a %lf Kelvin",temperatura, kelvin);
                break;
               }
          case 2:     
                {celsius = temperatura + CONVERSIONE_KC;
                 printf ("%lf Kelvin equivalgono a %lf Celsius", temperatura, celsius);
                 break;
                }
          case 3:
               {fahrenheit = CONVERSIONE_CF * temperatura + 32;
                printf ("%lf Celsius equivalgono a %lf Fahrenheit", temperatura, fahrenheit);
                break;
               }        
          case 4:
               {celsius =  (fahrenheit - 32) /CONVERSIONE_CF ;
                printf ("%lf Fahrenheit equivalgono a %lf Celsius", temperatura, celsius);
                break;
               }        
          default:
               printf("Errore: la scelta deve essere tra 1 e 4!");
   }
   getch();
   return 0;
}

