Guest User

Untitled

a guest
Apr 21st, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.32 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleColorProject
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. Console.WriteLine();
  10. Start();
  11. }
  12.  
  13. static void Calculator()
  14. {
  15. string str;
  16. double firstNum;
  17. double secNum;
  18. char op;
  19.  
  20. do
  21. {
  22. Console.WriteLine();
  23. Console.Write("First number: ");
  24. str = Console.ReadLine();
  25.  
  26. if (str == "exit")
  27. {
  28. Console.WriteLine();
  29. Start();
  30. }
  31.  
  32. firstNum = Convert.ToDouble(str);
  33.  
  34. Console.Write("Operator: ");
  35. op = Convert.ToChar(Console.ReadLine());
  36.  
  37. Console.Write("Second number: ");
  38. secNum = Convert.ToDouble(Console.ReadLine());
  39.  
  40. double erg1 = firstNum + secNum;
  41. double erg2 = firstNum - secNum;
  42. double erg3 = firstNum * secNum;
  43. double erg4 = firstNum / secNum;
  44.  
  45. switch (op)
  46. {
  47. case '+': Console.WriteLine(erg1); break;
  48. case '-': Console.WriteLine(erg2); break;
  49. case '*': Console.WriteLine(erg3); break;
  50. case '/': Console.WriteLine(erg4); break;
  51. }
  52. Console.WriteLine();
  53.  
  54. } while (true);
  55. }
  56.  
  57.  
  58. static void Start()
  59. {
  60. Console.WriteLine("(Type in the number and press ENTER to select. Type in 'exit' after 'First Number' comes up to go back to the menu.)");
  61. Console.WriteLine("1) Background color");
  62. Console.WriteLine("2) Font color");
  63. Console.WriteLine("3) Start program");
  64. int x = Convert.ToInt32(Console.ReadLine());
  65.  
  66. switch (x)
  67. {
  68. case 1: ConsoleBG(); break;
  69. case 2: ConsoleFG(); break;
  70. case 3: Calculator(); break;
  71. }
  72. Start();
  73. }
  74.  
  75. static void ConsoleBG()
  76. {
  77. Console.WriteLine();
  78. Console.WriteLine("1) green, "+"2) yellow, "+"3) red, "+"4) darkblue, "+"5) back");
  79. int x = Convert.ToInt32(Console.ReadLine());
  80.  
  81. switch (x)
  82. {
  83. case 1: Console.BackgroundColor = ConsoleColor.Green; break;
  84. case 2: Console.BackgroundColor = ConsoleColor.Yellow; break;
  85. case 3: Console.BackgroundColor = ConsoleColor.Red; break;
  86. case 4: Console.BackgroundColor = ConsoleColor.DarkBlue; break;
  87. case 5: Start(); break;
  88. }
  89. Console.Clear();
  90. Start();
  91. }
  92.  
  93.  
  94. static void ConsoleFG()
  95. {
  96. Console.WriteLine();
  97. Console.WriteLine("1) white, "+"2) black, "+"3) blue, "+"4) back");
  98. int x = Convert.ToInt32(Console.ReadLine());
  99.  
  100. switch (x)
  101. {
  102. case 1: Console.ForegroundColor = ConsoleColor.White; break;
  103. case 2: Console.ForegroundColor = ConsoleColor.Black; break;
  104. case 3: Console.ForegroundColor = ConsoleColor.Blue; break;
  105. case 4: Start(); break;
  106. }
  107. Console.WriteLine();
  108. Start();
  109. }
  110. }
  111. }
Add Comment
Please, Sign In to add comment