Advertisement
Guest User

Calculator in console by raxe modz

a guest
Apr 16th, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.79 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 My_first_project
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. calculator();
  14.  
  15. }
  16.  
  17. private static void calculator()
  18. {
  19. userStart:
  20. Console.ForegroundColor = ConsoleColor.Green;
  21. Console.Write("User : ");
  22. String user = Console.ReadLine();
  23. if (user == "raxemodz")
  24. {
  25. passwordStart:
  26. Console.Write("Password : ");
  27. String password = Console.ReadLine();
  28. if (password == "hatemyself")
  29. {
  30. mainStart:
  31. Console.Clear();
  32. Console.WriteLine("Hello, " + user + " and welcome to my first calculator programmed in C#.");
  33. Console.WriteLine("----------------------------------------------------------------------------");
  34. Console.WriteLine("1. Division\n2. Multiplication\n3. Addition\n4. Substraction");
  35. Console.Write("Choise : ");
  36. String choise = Console.ReadLine();
  37.  
  38.  
  39. if (choise == "1")
  40. {
  41. divisionStart:
  42. double firstNumber;
  43. double secondNumbers;
  44.  
  45. Console.Clear();
  46. Console.WriteLine("-----------------------------");
  47. Console.Write("First number : ");
  48. firstNumber = Convert.ToDouble(Console.ReadLine());
  49. Console.Write("Second numbers : ");
  50. secondNumbers = Convert.ToDouble(Console.ReadLine());
  51. Console.WriteLine("Result : " + firstNumber / secondNumbers);
  52. Console.WriteLine("-----------------------------");
  53. Console.ReadKey();
  54. Console.ReadLine();
  55. goto divisionStart;
  56. }
  57. else if (choise == "2")
  58. {
  59. multiplicationStart:
  60. int firstNumber;
  61. int secondNumbers;
  62.  
  63. Console.Clear();
  64. Console.WriteLine("-----------------------------");
  65. Console.Write("First number : ");
  66. firstNumber = Convert.ToInt32(Console.ReadLine());
  67. Console.Write("Second numbers : ");
  68. secondNumbers = Convert.ToInt32(Console.ReadLine());
  69. Console.WriteLine("Result : " + firstNumber * secondNumbers);
  70. Console.WriteLine("-----------------------------");
  71. Console.ReadKey();
  72. Console.ReadLine();
  73. goto multiplicationStart;
  74. }
  75. else if (choise == "3")
  76. {
  77. additionStart:
  78. int firstNumber;
  79. int secondNumber;
  80. Console.Clear();
  81. Console.WriteLine("-----------------------------");
  82. Console.Write("First number : ");
  83. firstNumber = Convert.ToInt32(Console.ReadLine());
  84. Console.Write("Second number : ");
  85. secondNumber = Convert.ToInt32(Console.ReadLine());
  86. Console.WriteLine("Result : " + (firstNumber + secondNumber));
  87. Console.WriteLine("-----------------------------");
  88. Console.ReadKey();
  89. Console.ReadLine();
  90. goto additionStart;
  91. }
  92. else if (choise == "4")
  93. {
  94. substractionStart:
  95. int firstNumber;
  96. int secondNumber;
  97. Console.Clear();
  98. Console.WriteLine("-----------------------------");
  99. Console.Write("First number : ");
  100. firstNumber = Convert.ToInt32(Console.ReadLine());
  101. Console.Write("Second number : ");
  102. secondNumber = Convert.ToInt32(Console.ReadLine());
  103. Console.WriteLine("Result : " + (firstNumber - secondNumber));
  104. Console.WriteLine("-----------------------------");
  105. Console.ReadKey();
  106. Console.ReadLine();
  107. goto substractionStart;
  108. }
  109. else
  110. {
  111. Console.WriteLine("Wrong value please try again :/");
  112. Console.ReadKey();
  113. Console.ReadLine();
  114. goto mainStart;
  115. }
  116. }
  117. else
  118. {
  119. Console.Clear();
  120. Console.WriteLine("You enter the wrong password please try again :/");
  121. Console.ReadKey();
  122. Console.ReadLine();
  123. goto passwordStart;
  124. }
  125. }
  126. else
  127. {
  128. Console.Clear();
  129. Console.WriteLine("You enter the wrong user please try again :/");
  130. Console.ReadKey();
  131. Console.ReadLine();
  132. goto userStart;
  133. }
  134. Console.ReadLine();
  135. }
  136. }
  137. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement