#include <stdio.h>
#include <conio.h>
int main()
{
int i,j;
char choice;
float celsius,fahrenheit,kelvin;
clrscr();
printf(" *****************************************************\n");
printf(" * 1. Celsius change into Fahrenheit *\n");
printf(" * 2. Fahrenheit change into Celsius *\n");
printf(" * 3. Celsius change into Kelvin *\n");
printf(" * 4. Exit *\n");
printf(" *****************************************************\n\n");
printf(" Please your choice(1-4): ");
while(1)
{
scanf("%c",&choice);
if(choice>='1' && choice<='4')
{
printf("\n");
i=(int)(choice-'0');
switch(i)
{
case 1:
{
printf(" Please input Celsius: ");
scanf("%f",&celsius);
fahrenheit=celsius*9.0/5+32.0;
printf("\n");
printf(" The Fahrenheit is: %5.2f\n\n",fahrenheit);
break;
}
case 2:
{
printf(" Please input Fahrenheit: ");
scanf("%f",&fahrenheit);
celsius=(fahrenheit-32.0)*5.0/9;
printf("\n");
printf(" The Celsius is: %5.2f\n\n",celsius);
break;
}
case 3:
{
printf(" Please input Celsius: ");
scanf("%f",&celsius);
kelvin=celsius+273.15;
printf("\n");
printf(" The Kelvin is: %5.2f\n\n",kelvin);
break;
}
case 4: exit(0);
}
printf(" Please press any key to continue...");
getch();
for(j=9;j<=19;j++)
{
gotoxy(1,j);
clreol();
}
gotoxy(28,8);
clreol();
continue;
}
else
{
gotoxy(28,8);
clreol();
gotoxy(28,8);
continue;
}
}
return 0;
}