We have to write a program to convert a user entered Kelvin temperature to either celsius or fahrenheit and also display the state of the water. I found the same question on here and used it to fix some problems I was having, but I still can't compile and I don't know what I'm doing wrong.
/* Program to convert temperature and display state */
#include <stdio.h>
/* Get user input */
void getTemp (int kelvin)
{
printf("Welcome to the temperature conversion program.\n");
printf("Please enter a the sample temperature in Degrees Kelvin: \n");
scanf("%d%*c", &kelvin);
return ();
}
/* Convert temperature */
void getType (char type)
{
int kelvin, celsius, fahrenheit;
printf("Do you wish to convert the temperature to (c) for Celsius, or (f) for Fahrenheit? \n");
scanf("%c%*c", &type);
switch(type)
{
case 'c':
celsius = convC(kelvin, celsius);
break;
case 'f':
fahrenheit = convF (fahrenheit, celsius, kelvin);
break;
default:
printf("You have entered an invalid option");
break;
}
return ();
}
void convC (int kelvin, int celsius)
{
(celsius = (kelvin - 273));
if(celsius > 99)
{
printf("The water is in a gas state at %d degrees celsius.\n", celsius);
}
if(celsius > 0 && celsius < 100)
{
printf("The water is in a liquid state at %d degrees celsius.\n", celsius);
}
if(celsius < 1)
{
printf("The water is in a solid state at %d degrees celsius.\n", celsius);
}
return();
}
void convF (int kelvin, int celsius, int fahrenheit)
{
(celsius = (kelvin - 273));
(fahrenheit = (9 * celsius / 5) + 32));
if(fahrenheit > 210.2)
{
printf("The water is in a gas state at %d degrees fahrenheit.\n", fahrenheit);
}
if(fahrenheit > 32 && fahrenheit < 212)
{
printf("The water is in a liquid state at %d degrees fahrenheit.\n", fahrenheit);
}
if(fahrenheit < 33)
{
printf("The water is in a solid state at %d degrees fahrenheit.\n", fahrenheit);
}
return();
}
int main ()
{
int kelvin;
char type;
getTemp(kelvin);
getType(type);
return (0);
}