P
Professor Pyg
Guest
Hi, would need help on why my value "celsius" doesn't work in the "while (celsius > 77 || celsius < 73);" is there any particular I have to do, to extract it from the "public static double FahrenheitToCelsius(int fahrenheit)"?
using System;
namespace Bastun
{
class Program
{
static void Main(string[] args)
{
do
{
Console.WriteLine("Write your fahrenheit ");
//User inputs a value that is saved in fahrenheit
int fahrenheit = Int32.Parse(Console.ReadLine());
//Fahrenheit has now been converted to celsius
double celsius = FahrenheitToCelsius(fahrenheit);
Console.WriteLine("Your farhrenheit has been calculated to celsius, the current temperature in the bastu is " + celsius + " celsius");
if (celsius < 73)
{
Console.WriteLine("It's too cold, turn it up a bit!");
}
else if (celsius > 77)
{ Console.WriteLine("It's too hot, turn it down a bit!"); }
else if (73 <= celsius && celsius <= 77)
{ Console.WriteLine("It's a good temperature!"); }
} while (celsius > 77 || celsius < 73);
}
public static double FahrenheitToCelsius(int fahrenheit)
{
//From fahrenheit to celsius
double celsius = (fahrenheit - 32) * 5 / 9;
return celsius;
}
}
}
Continue reading...
using System;
namespace Bastun
{
class Program
{
static void Main(string[] args)
{
do
{
Console.WriteLine("Write your fahrenheit ");
//User inputs a value that is saved in fahrenheit
int fahrenheit = Int32.Parse(Console.ReadLine());
//Fahrenheit has now been converted to celsius
double celsius = FahrenheitToCelsius(fahrenheit);
Console.WriteLine("Your farhrenheit has been calculated to celsius, the current temperature in the bastu is " + celsius + " celsius");
if (celsius < 73)
{
Console.WriteLine("It's too cold, turn it up a bit!");
}
else if (celsius > 77)
{ Console.WriteLine("It's too hot, turn it down a bit!"); }
else if (73 <= celsius && celsius <= 77)
{ Console.WriteLine("It's a good temperature!"); }
} while (celsius > 77 || celsius < 73);
}
public static double FahrenheitToCelsius(int fahrenheit)
{
//From fahrenheit to celsius
double celsius = (fahrenheit - 32) * 5 / 9;
return celsius;
}
}
}
Continue reading...