Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleCalculator_by_Godness
  8. {
  9. public class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. n();
  14. Console.ReadKey();
  15.  
  16. }
  17. public static int n()
  18. {
  19. //Обьявление переменных куда будут записываться числа
  20. char operators;
  21. double First;
  22. double Second;
  23. double result;
  24. //Конвертирование в консоль(сделать так чтобы можно было вводить числа в консоль, записывание)
  25. Console.WriteLine("Введите оператор");
  26. operators = Convert.ToChar(Console.ReadLine());
  27. Console.WriteLine("Введите первое число", ConsoleColor.Red);
  28. First = Convert.ToDouble(Console.ReadLine());
  29. Console.WriteLine("Введите второе");
  30. Second = Convert.ToDouble(Console.ReadLine());
  31.  
  32. if (operators == '+')
  33. {
  34. result = First + Second;
  35. Console.WriteLine("Сумма чисел " + First + " и " + Second + " = " + result);
  36.  
  37. //Почему (int)? Да блядская визуалка говорит что result нельзя в int переобразовать, вот я и привел тип int
  38.  
  39. }
  40. if (operators == '-')
  41. {
  42. result = First - Second;
  43. Console.WriteLine("Результат вычитания чисел " + First + " - " + Second + " = " + result);
  44. }
  45. if (operators == '*')
  46. {
  47. result = First * Second;
  48. Console.WriteLine("Результат умножения двух чисел " + First + " * "+ Second + " = " + result);
  49. }
  50.  
  51. return n();
  52. }
  53.  
  54.  
  55. }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement