Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.68 KB | None | 0 0
  1. {
  2. class Program
  3. {
  4. static void Main(string[] args)
  5. {
  6. Console.WriteLine("Patrik Kratochvíl,Trojuhelník/Pravidelný 6-úhelník"); //Jméno,Obrazec1/Obrazec2
  7.  
  8. Console.WriteLine("Vyberte obrazec:");
  9. Console.WriteLine("Pro Trojuhelnik zadejte 1");
  10. Console.WriteLine("Pro Šestiúhelník zadejte 2");
  11.  
  12. string obrazec;
  13.  
  14. obrazec = Console.ReadLine();
  15.  
  16. while (obrazec != "konec")
  17. {
  18. if (obrazec == "1") ;
  19. {
  20. Console.WriteLine("Zadejte delku stranyA");
  21. int delkastranyA;
  22.  
  23. string VyslednaDelkaA;
  24.  
  25. VyslednaDelkaA = Console.ReadLine();
  26.  
  27. delkastranyA = KontrolaCisla(VyslednaDelkaA);
  28.  
  29. Console.WriteLine("Zadejte delku stranyB");
  30. int delkastranyB;
  31.  
  32. string VyslednaDelkaB;
  33.  
  34. VyslednaDelkaB = Console.ReadLine();
  35.  
  36. delkastranyB = KontrolaCisla(VyslednaDelkaB);
  37.  
  38. Console.WriteLine("Zadejte delku stranyC");
  39. int delkastranyC;
  40.  
  41. string VyslednaDelkaC;
  42.  
  43. VyslednaDelkaC = Console.ReadLine();
  44.  
  45. delkastranyC = KontrolaCisla(VyslednaDelkaC);
  46.  
  47. Console.WriteLine("Zadejte vysku");
  48. int vyska;
  49.  
  50. string Vyslednavyska;
  51.  
  52. Vyslednavyska = Console.ReadLine();
  53.  
  54. vyska = KontrolaCisla(Vyslednavyska);
  55.  
  56. Console.WriteLine("Zadejte delku strany k vysce");
  57. int delkaStranyKvysce;
  58.  
  59. string VyslednaDelkaStranyKvysce;
  60.  
  61. VyslednaDelkaStranyKvysce = Console.ReadLine();
  62.  
  63. delkaStranyKvysce = KontrolaCisla(VyslednaDelkaStranyKvysce);
  64.  
  65.  
  66.  
  67. ObvodTrojuhelniku(delkastranyA, delkastranyB, delkastranyC);
  68. ObsahTrojuhelniku(delkaStranyKvysce, vyska);
  69.  
  70.  
  71.  
  72. Console.WriteLine("Chcete počítat znovu?");
  73. Console.WriteLine("Pokud ano zadejte 1");
  74. Console.WriteLine("Pokud ne zadejte 2");
  75.  
  76. string chcetePocitatZnovu;
  77.  
  78. chcetePocitatZnovu = Console.ReadLine();
  79.  
  80. while (chcetePocitatZnovu != "konec")
  81.  
  82. {
  83. if (chcetePocitatZnovu == "1") ;
  84. {
  85.  
  86. }
  87.  
  88. }
  89.  
  90.  
  91. }
  92. if (obrazec == "2") ;
  93. {
  94. Console.WriteLine("Zadejte delku strany");
  95.  
  96. int delkastranyA6;
  97.  
  98. string VyslednaDelkaA6;
  99.  
  100. VyslednaDelkaA6 = Console.ReadLine();
  101.  
  102. delkastranyA6 = KontrolaCisla(VyslednaDelkaA6);
  103.  
  104. ObsahSestiuhelniku(delkastranyA6);
  105. }
  106.  
  107.  
  108. }
  109.  
  110.  
  111.  
  112. static void ObsahTrojuhelniku(int delkastrany, int vyska)
  113. {
  114. int obsah;
  115. obsah = delkastrany * vyska / 2;
  116. Console.WriteLine($"obsah trojuhelniku je { obsah}");
  117. }
  118.  
  119. static void ObvodTrojuhelniku(int stranaA, int stranaB, int stranaC)
  120. {
  121. int obvod;
  122. obvod = stranaA + stranaB + stranaC;
  123. Console.WriteLine($"obvod trojuhelniku je { obvod}");
  124. }
  125.  
  126. static void ObsahSestiuhelniku(int stranaA)
  127. {
  128. double obsah;
  129. obsah = (3 * Math.Sqrt(3)) / 2 * stranaA * stranaA;
  130. Console.WriteLine($"obsah pravidelneho sestiuhelniku je { obsah}");
  131. }
  132.  
  133. static void ObvodSestiuhelniku(int stranaA)
  134. {
  135. int obvod;
  136. obvod = stranaA * 6;
  137. Console.WriteLine($"obvod pravidelneho sestiuhelniku je { obvod}");
  138. }
  139.  
  140. static int KontrolaCisla(string KontrolovaneCislo)
  141. {
  142. int number = -1;
  143.  
  144. while (number <= 0)
  145.  
  146. if (!Int32.TryParse(KontrolovaneCislo, out number))
  147. {
  148. Console.WriteLine("Zadal jste spatnou hodnotu");
  149. KontrolovaneCislo = Console.ReadLine();
  150. }
  151.  
  152. if (number <= 0)
  153. {
  154. Console.WriteLine("Zadejte novou hodnotu");
  155. }
  156.  
  157. return number;
  158.  
  159. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement