Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.67 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 Zadanie1_Lab3
  8. {
  9.  
  10.  
  11. class Program
  12. {
  13. static void Main(string[] args)
  14. {
  15. Rect[] tablica = new Rect[3];
  16.  
  17. for(int i=0; i < tablica.Length; i++)
  18. {
  19. tablica[i] = new Rect();
  20. }
  21.  
  22.  
  23. Console.WriteLine("Witamy w programie obliczajacym pole i obwod prostokatu, prosze podac nastepujace dane dla trzech prostokatow.");
  24. Console.WriteLine("Aby przejsc do deklaracji prosokatow prosze wcisnac dowolny klawisz:");
  25. Console.ReadKey();
  26.  
  27. for (int i = 0; i < tablica.Length; i++)
  28. {
  29.  
  30. Console.WriteLine("Prosze podac szerokosc dla prostokatu {0}: ", i + 1);
  31. double k = double.Parse(Console.ReadLine());
  32. Console.WriteLine("Prosze podac wysokosc dla prostokatu {0}: ", i + 1);
  33. double l = double.Parse(Console.ReadLine());
  34. Console.WriteLine("Prosze podac kolor dla prostokatu {0}: ", i + 1);
  35. String o = Console.ReadLine();
  36. tablica[i].setRect(k,l,o);
  37.  
  38. }
  39.  
  40. Console.WriteLine("Aby kontynuowac i wyswietlic parametry prostokatow prosze wcisnac dowolny klawisz");
  41. Console.ReadKey();
  42.  
  43. for (int i =0; i < tablica.Length; i++)
  44. {
  45. Console.WriteLine("Parametry dla prostokatu nr {0}", i + 1);
  46. tablica[i].showRectParams();
  47. }
  48.  
  49. Console.Write("Prosze wcisnac dowolny klawisz aby przejsc dalej:");
  50. Console.ReadLine();
  51.  
  52. Console.WriteLine("Prosze podac wartosc graniczna pola powierzchni: ");
  53. double poleGranicz = double.Parse(Console.ReadLine());
  54.  
  55. if (tablica[0].getArea() > poleGranicz && tablica[1].getArea() > poleGranicz && tablica[2].getArea() > poleGranicz)
  56. {
  57. Console.WriteLine("Zadne pole nie spelnia warunku.");
  58. }
  59. else
  60. {
  61. for (int i = 0; i < tablica.Length; i++)
  62. {
  63. if (tablica[i].getArea() <= poleGranicz)
  64. {
  65. Console.WriteLine("Prostokat nr {0} spelnia warunek graniczny majac pole rowne {1}", i + 1, tablica[i].getArea());
  66. Console.WriteLine("oraz o parametrach: ");
  67. tablica[i].showRectParams();
  68. }
  69. }
  70. }
  71.  
  72.  
  73. Console.ReadKey();
  74. }
  75. }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement