Advertisement
MartinGeorgiev

points

Oct 10th, 2022 (edited)
716
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.31 KB | None | 0 0
  1. using System;
  2. using Asen_Kursova;
  3.  
  4. namespace Asen_Kursova
  5. {
  6.   internal class Program
  7.   {
  8.     static void Main (string[]args)
  9.     {
  10.  
  11.       Points[]points = new Points[10];
  12.       String[]names = {"first","second","third","forth","fifth","sixth","seventh","eighth","ninth","tenth"}
  13.       int bestIndex = -1;
  14.       double distance = -1;
  15.       for (int i = 0; i < points.Length; i++)
  16.     {
  17.       Points current = new Points();
  18.         current.Name = names[i];
  19.         Console.WriteLine ($ "distance number {i+1} is ");
  20.         points[i] = current;
  21.         points[i].InputDots ();
  22.         points[i].AreaOfDots ();
  23.       if (points[i].Distance > distance)
  24.         {
  25.           distance = points[i].Distance;
  26.           bestIndex = i;
  27.         }
  28.  
  29.     }
  30.  
  31.       Console.WriteLine ($"The biggest distance is {points[bestIndex].Name} with distance {points[bestIndex].Distance:f2}");
  32.     }
  33.   }
  34. }
  35.  
  36. using System;
  37. using System.Collections.Generic;
  38. using System.Linq;
  39. using System.Text;
  40. using System.Threading.Tasks;
  41.  
  42. namespace Vladislav_Kursova
  43. {
  44.   internal class Points
  45.   {
  46.     private double x1, y1, x2, y2, distance;
  47.     private string name;
  48.     public Points (){}
  49.     public Points (double x_1, double y_1, double x_2, double y_2,double areas, string name)
  50.     {
  51.       this.x1 = x_1;
  52.       this.y1 = y_1;
  53.       this.x2 = x_2;
  54.       this.y2 = y_2;
  55.       this.distance = areas;
  56.       this.name = name;
  57.     }
  58.     public double X1
  59.     {
  60.  
  61.       set = >x1 = value;
  62.     }
  63.     public double Y1
  64.     {
  65.  
  66.       set = >y1 = value;
  67.     }
  68.     public double X2
  69.     {
  70.  
  71.       set = >x2 = value;
  72.     }
  73.     public double Y2
  74.     {
  75.  
  76.       set = >y2 = value;
  77.     }
  78.     public double Distance
  79.     {
  80.       get = >distance;
  81.  
  82.     }
  83.     public string Name
  84.     {
  85.       get = >name;
  86.       set = >name = value;
  87.     }
  88.     public void InputDots ()
  89.     {
  90.       Console.Write ("enter x1 ");
  91.       x1 = double.Parse (Console.ReadLine ());
  92.       Console.Write ("enter y1 ");
  93.       y1 = double.Parse (Console.ReadLine ());
  94.       Console.Write ("enter x2 ");
  95.       x2 = double.Parse (Console.ReadLine ());
  96.       Console.Write ("enter y2 ");
  97.       y2 = double.Parse (Console.ReadLine ());
  98.     }
  99.     public double AreaOfDots () = >distance =
  100.       Math.Sqrt (Math.Pow (x2 - x1, 2) + Math.Pow (y2 - y1, 2));
  101.  
  102.   }
  103.  
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement