Advertisement
Guest User

Untitled

a guest
Mar 2nd, 2018
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp1
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. Console.Title = "Calculator";
  10. Console.ForegroundColor = ConsoleColor.Red;
  11. Console.BackgroundColor = ConsoleColor.White;
  12. Console.WriteLine("Здравствуйте! Это мой калькулятор, введите 1 число");
  13. Console.Write("Число: ");
  14. float a1 = float.Parse(Console.ReadLine());
  15. Console.WriteLine(" ");
  16. Console.WriteLine("Выберите действие, pl, mi, mu, de");
  17. Console.Write("Действие: ");
  18. string action1 = Console.ReadLine();
  19. Console.WriteLine(" ");
  20. Console.WriteLine("Введите 2-ое число и готово!");
  21. Console.Write("Число: ");
  22. float a2 = float.Parse(Console.ReadLine());
  23. Console.WriteLine(" ");
  24. Console.WriteLine(Calculate(action1, a2, a1));
  25. Console.WriteLine(" ");
  26. Console.WriteLine("Нажмите что бы выйти!");
  27. Console.ReadKey();
  28. }
  29. public static int Calculate(string action1, float a2, float a1)
  30. {
  31. switch (action1){
  32. case "pl":
  33. return a1 + a2;
  34. case "mi":
  35. return a1 - a2;
  36. case "mu":
  37. return a1 * a2;
  38. case "de":
  39. return a1 / a2;
  40. default:
  41. Console.Write("Error ");
  42. break;
  43. }
  44. return 101;
  45. }
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement