Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
134
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. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleDemo
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. while (true)
  14. {
  15. Console.WriteLine(">>> MENU <<<");
  16. Console.WriteLine("1 - Dodaj 2 liczby");
  17. Console.WriteLine("2 - Odejmij 2 liczby");
  18. Console.WriteLine("3 - Oblicz sume n liczb");
  19. Console.WriteLine("4 - Oblicz sume liczb dodatnich");
  20. Console.WriteLine("5 - Koniec");
  21. int opcja = int.Parse(Console.ReadLine());
  22. switch (opcja)
  23.  
  24. {
  25. case 1:
  26. Console.WriteLine("Podaj pierwsza liczbe");
  27. string liczba1 = Console.ReadLine();
  28. float a = float.Parse(liczba1);
  29. Console.WriteLine("Podaj druga liczbe");
  30. string liczba2 = Console.ReadLine();
  31. float b = float.Parse(liczba2);
  32. float suma = a + b;
  33. Console.WriteLine("Suma podanych liczb to:" + suma);
  34. Console.WriteLine("");
  35. break;
  36.  
  37. case 2:
  38. Console.WriteLine("Podaj pierwsza liczbe");
  39. string liczba1 = Console.ReadLine();
  40. float a = float.Parse(s: liczba1);
  41. Console.WriteLine("Podaj druga liczbe");
  42. string liczba2 = Console.ReadLine();
  43. float b = float.Parse(s: liczba2);
  44. float roznica = a - b;
  45. Console.WriteLine("Roznica podanych liczb to:" - roznica);
  46. Console.WriteLine("");
  47. break;
  48.  
  49. /* case 3:
  50. int suma = 0;
  51.  
  52. do
  53. {
  54. Console.WriteLine("podaj n");
  55. int dana = int.Parse(Console.ReadLine());
  56. if (dana == 0)
  57. break;
  58. suma += dana;
  59. Console.WriteLine("twoja suma: \n" + suma);
  60. } while (true);
  61. Console.ReadKey();
  62. */
  63. case 4:
  64. Console.WriteLine("Podaj pierwsza liczbe");
  65. string liczba1 = Console.ReadLine();
  66. float a = float.Parse(liczba1);
  67. Console.WriteLine("Podaj druga liczbe");
  68. string liczba2 = Console.ReadLine();
  69. float b = float.Parse(liczba2);
  70. float suma = a + b;
  71. Console.WriteLine(value: "Wynik z podanych liczb to:" + suma);
  72. Console.WriteLine("");
  73. break;
  74.  
  75. case ConsoleKey.Escape:
  76. case 5:
  77. Environment.Exit(0);
  78. break;
  79.  
  80. default: break;
  81. }
  82. }
  83. }
  84. }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement