You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.9 KiB
60 lines
1.9 KiB
1 year ago
|
int main()
|
||
|
{
|
||
|
float Celsius, Fahrenheit, Kelvin;
|
||
|
int choice;
|
||
|
|
||
|
printf("Hello, this program is a converter for the temperature \n");
|
||
|
printf("You need a choice for Celsius, Fahrenheit, Kelvin \n");
|
||
|
printf("1 = Celsius, 2 = Fahrenheit, 3 = Kelvin \n");
|
||
|
scanf("%d", &choice);
|
||
|
|
||
|
while(1)
|
||
|
{
|
||
|
switch (choice)
|
||
|
{
|
||
|
case 1:
|
||
|
printf("The Celsius is: \n");
|
||
|
scanf("%f", &Celsius);
|
||
|
|
||
|
Fahrenheit = (Celsius * (9.f/5.f)) + 32.f;
|
||
|
Kelvin = Celsius + 273.15f;
|
||
|
|
||
|
printf("Fahrenheit = (Celsius * 9/5) + 32 \n");
|
||
|
printf("%f degrees Celsius equals %f degrees Fahrenheit \n", Celsius, Fahrenheit);
|
||
|
printf("Kelvin = Celsius + 273.15\n");
|
||
|
printf("%f degrees Celsius equals %f degrees Kelvin \n", Celsius, Kelvin);
|
||
|
break;
|
||
|
|
||
|
case 2:
|
||
|
printf("The Fahrenheit is: \n");
|
||
|
scanf("%f", &Fahrenheit);
|
||
|
|
||
|
Fahrenheit = (Celsius * 1.8f);
|
||
|
Kelvin = Celsius - 273.15f;
|
||
|
|
||
|
printf("Fahrenheit = (Celsius * 1.8) \n");
|
||
|
printf("%f degrees Fahrenheit equals %f degrees Celsius \n", Fahrenheit, Celsius);
|
||
|
printf("Fahrenheit = (Celsius * 1.8) \n");
|
||
|
printf("Kelvin = Fahrenheit equals %f degrees Kelvin \n", Fahrenheit, Kelvin);
|
||
|
break;
|
||
|
|
||
|
case 3:
|
||
|
printf("The Kelvin is: \n");
|
||
|
scanf("%f", &Kelvin);
|
||
|
|
||
|
Kelvin = Fahrenheit (1.8f * Kelvin) - 459.67f;
|
||
|
Kelvin = Celsius - 273.15f;
|
||
|
|
||
|
printf("Kelvin = (Fahrenheit * 1.8) \n");
|
||
|
printf("%f degrees Fahrenheit equals %f degrees Kelvin \n", Kelvin, Celsius);
|
||
|
printf("Kelvin =(Celsius * 1.8)\n");
|
||
|
printf("Kelvin = Fahrenheit equals %f degrees Kelvin \n", Fahrenheit, Kelvin);
|
||
|
break;
|
||
|
|
||
|
default:
|
||
|
printf("The value is not a number !");
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
return(0);
|
||
|
}
|