Advertisement
Guest User

Untitled

a guest
Dec 16th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 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 SimpleCalculator
  8. {
  9. class kalkulator
  10. {
  11. static void Main(string[] args)
  12. {
  13. int dzialanie = 0;
  14. double result = 0;
  15.  
  16.  
  17. Console.WriteLine("Podaj liczbę pierwszą :");
  18. int pierwsza = Convert.ToInt32(Console.ReadLine());
  19.  
  20.  
  21.  
  22. Console.WriteLine("Podaj liczbę drugą :");
  23. int druga = Convert.ToInt32(Console.ReadLine());
  24.  
  25.  
  26.  
  27. Console.WriteLine("Co chcesz zrobic? + (dodac), - (odjac), * (pomnozyc), / (podzielic)? :");
  28. string opcja = Console.ReadLine();
  29.  
  30.  
  31. if (opcja == "+" || opcja == "dodac")
  32. {
  33. dzialanie = 1;
  34. }
  35. else if (opcja == "-" || opcja == "odjac")
  36. {
  37. dzialanie = 2;
  38. }
  39. else if (opcja == "*" || opcja == "pomnozyc")
  40. {
  41. dzialanie = 3;
  42. }
  43. else if (opcja == "/" || opcja == "podzielic")
  44. {
  45. dzialanie = 4;
  46. }
  47.  
  48.  
  49. switch (dzialanie)
  50. {
  51. case 1:
  52. result = pierwsza + druga;
  53. break;
  54.  
  55. case 2:
  56. result = pierwsza - druga;
  57. break;
  58.  
  59. case 3:
  60. result = pierwsza * druga;
  61. break;
  62.  
  63. case 4:
  64. result = pierwsza / druga;
  65. break;
  66.  
  67. }
  68. Console.WriteLine("Wynik: " + pierwsza + " " + opcja + " " + druga + " = " + result + ".");
  69. Console.WriteLine("");
  70. Console.WriteLine("");
  71. Console.WriteLine("Aby wyłączyc wcisnik klawisz 'q', aby kontynuowac wcisnij dowolny klawisz");
  72.  
  73.  
  74.  
  75. }
  76. }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement