Converting int to double to output with decimals
Hello again! i got a little problem with converting int to double, i dont get it to output the decimals and i dont know where i do wrong ^^
Any tips?
Any tips?
public static void Main (string[] args)
{
double celsius = 0;
int fahr;
do
{
/*
+---------------------------+
| Here i input the integer! |
+---------------------------+
*/
Console.WriteLine("Write temp in fahrenheit: ");
fahr = int.Parse(Console.ReadLine());
celsius = FahrToCels(fahr);
Console.WriteLine("Your value in Celsius: " + celsius);
if (celsius < 82)
{
Console.WriteLine("Too Cold!");
}
else if (celsius > 87)
{
Console.WriteLine("Too Hot!");
}
} while (celsius < 82 || celsius > 87);
Console.WriteLine("Temp is ok! Enjoy!");
/*
+-------------------------------------+
| Here i want to output with decimals |
+-------------------------------------+
*/
Console.WriteLine("Fahrenheit: " + fahr);
Console.WriteLine("Celsius: " + celsius + "\n");
}
/*
+--------------------------------------------------------------------------------+
| Here i want to convert integer to double to output with decimals in code above |
+--------------------------------------------------------------------------------+
*/
public static double FahrToCels(int fahr)
{
double cel = (fahr - 32) * 5 / 9;
return cel;
} public static void Main (string[] args)
{
double celsius = 0;
int fahr;
do
{
/*
+---------------------------+
| Here i input the integer! |
+---------------------------+
*/
Console.WriteLine("Write temp in fahrenheit: ");
fahr = int.Parse(Console.ReadLine());
celsius = FahrToCels(fahr);
Console.WriteLine("Your value in Celsius: " + celsius);
if (celsius < 82)
{
Console.WriteLine("Too Cold!");
}
else if (celsius > 87)
{
Console.WriteLine("Too Hot!");
}
} while (celsius < 82 || celsius > 87);
Console.WriteLine("Temp is ok! Enjoy!");
/*
+-------------------------------------+
| Here i want to output with decimals |
+-------------------------------------+
*/
Console.WriteLine("Fahrenheit: " + fahr);
Console.WriteLine("Celsius: " + celsius + "\n");
}
/*
+--------------------------------------------------------------------------------+
| Here i want to convert integer to double to output with decimals in code above |
+--------------------------------------------------------------------------------+
*/
public static double FahrToCels(int fahr)
{
double cel = (fahr - 32) * 5 / 9;
return cel;
}