Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- do
- {
- Console.Write("\nEnter desired temperature in Fahrenheit: "); // Skriver in grader i fahrenheit
- int fahrenheit = int.Parse(Console.ReadLine()); // Omvandla input till en int
- celsius = FahrToCels(fahrenheit); // Ropa hit tidigare metod för att omvandla Fahrenheit till Celsius
- if (celsius == optimalTemp)
- {
- Console.ForegroundColor = ConsoleColor.Green;
- Console.WriteLine("\nSuccess. You may now enter the sauna, {0}F/{1}°C is the optimal temperature for this sauna.\n", fahrenheit, celsius);
- Console.ResetColor();
- break;
- }
- else if (celsius > maximalTemp)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("\nError: Your temperature input {0}F/{1}°C is too hot for the sauna to handle.\nThis sauna only operate between the temperatures {2}°C and {3}°C.", fahrenheit, celsius, minimalTemp, maximalTemp);
- Console.ResetColor();
- continue;
- }
- else if (celsius < minimalTemp)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("\nError: Your temperature input {0}F/{1}°C is too cold for the sauna to handle.\nThis sauna only operate between the temperatures {2}°C and {3}°C.", fahrenheit, celsius, minimalTemp, maximalTemp);
- Console.ResetColor();
- continue;
- }
- else if (celsius >= minimalTemp || celsius <= maximalTemp)
- {
- Console.ForegroundColor = ConsoleColor.Green;
- Console.WriteLine("\nSuccess. You may now enter the sauna, {0}F/{1}°C is an accepted temperature for this sauna.\n", fahrenheit, celsius);
- Console.ResetColor();
- break;
- }
- else
- try
- {
- fahrenheit = int.Parse(Console.ReadLine());
- celsius = int.Parse(Console.ReadLine());
- }
- catch
- {
- Console.WriteLine("Error. Use a number.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement