import java.util.Scanner; public class Centroid { Scanner in = new Scanner(System.in); void start() { int caseNumber = 1; while (true) { int n = in.nextInt(); if (n < 0) return; float[] x = new float[n]; float[] y = new float[n]; float[] m = new float[n]; for (int i = 0; i < n; i++) { x[i] = in.nextFloat(); y[i] = in.nextFloat(); m[i] = in.nextFloat(); } process(caseNumber, x, y, m); caseNumber ++; } } void process(int caseNumber, float[] x, float[] y, float[] m) { float xNum = 0; float yNum = 0; float mTot = 0; for (int i = 0; i < x.length; i++) { xNum += x[i] * m[i]; yNum += y[i] * m[i]; mTot += m[i]; } float x_c = xNum / mTot; float y_c = yNum / mTot; System.out.printf("Case %d: %.2f %.2f\n", caseNumber, x_c, y_c); } public static void main(String[] args) { new Centroid().start(); } }