about summary refs log tree commit diff
path: root/usth/ICT2.2/labwork/4/Centroid.java
blob: 7862cbb357c9d48457a0e648b59ef3ed7ee338f5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import java.util.Scanner;

class Centriod
{
  public static void main(String... args)
  {
    var scanner = new Scanner(System.in);
    double m = 0.0, x = 0.0, y = 0.0;

    while (scanner.hasNextDouble())
      {
        double n = scanner.nextDouble();
        if (!scanner.hasNextDouble())
          break;
        double s = scanner.nextDouble();
        if (!scanner.hasNextDouble())
          break;
        double i = scanner.nextDouble();

        m += n;
        x += n * s;
        y += n * i;
      }
    System.out.println(m + " " + x/m + " " + y/m);
  }
}