parent
7e4692ed41
commit
4c0c6ddaf0
@ -0,0 +1,60 @@ |
||||
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); |
||||
} |
Loading…
Reference in new issue