Guest User

Untitled

a guest
Jul 22nd, 2019
57
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. do
  2. {
  3. Console.Write("\nEnter desired temperature in Fahrenheit: "); // Skriver in grader i fahrenheit
  4. int fahrenheit = int.Parse(Console.ReadLine()); // Omvandla input till en int
  5. celsius = FahrToCels(fahrenheit); // Ropa hit tidigare metod för att omvandla Fahrenheit till Celsius
  6.  
  7. if (celsius == optimalTemp)
  8. {
  9. Console.ForegroundColor = ConsoleColor.Green;
  10. Console.WriteLine("\nSuccess. You may now enter the sauna, {0}F/{1}°C is the optimal temperature for this sauna.\n", fahrenheit, celsius);
  11. Console.ResetColor();
  12. break;
  13. }
  14.  
  15. else if (celsius > maximalTemp)
  16. {
  17. Console.ForegroundColor = ConsoleColor.Red;
  18. 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);
  19. Console.ResetColor();
  20. continue;
  21. }
  22.  
  23. else if (celsius < minimalTemp)
  24. {
  25. Console.ForegroundColor = ConsoleColor.Red;
  26. 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);
  27. Console.ResetColor();
  28. continue;
  29. }
  30.  
  31. else if (celsius >= minimalTemp || celsius <= maximalTemp)
  32. {
  33. Console.ForegroundColor = ConsoleColor.Green;
  34. Console.WriteLine("\nSuccess. You may now enter the sauna, {0}F/{1}°C is an accepted temperature for this sauna.\n", fahrenheit, celsius);
  35. Console.ResetColor();
  36. break;
  37. }
  38.  
  39. else
  40.  
  41. try
  42. {
  43. fahrenheit = int.Parse(Console.ReadLine());
  44. celsius = int.Parse(Console.ReadLine());
  45. }
  46.  
  47. catch
  48. {
  49. Console.WriteLine("Error. Use a number.");
  50. }
  51. }
RAW Paste Data