import java.util.Scanner;
public class Vector 
{
  double x = 0.0;
  double y = 0.0;
  
  public static void main(String[] args) 
  { 
    System.out.println("Operaciones con vectores en el plano");
    
    Vector vector1 = null;
    Vector vector2 = new Vector();
    
    int contador = 1;
    do
    {
      System.out.println();
      System.out.println("Vector " + contador);
      vector2.leer();
      System.out.print("V" + contador + ": ");
      vector2.imprimir();
      
      if (contador > 1)
      {
        System.out.print("V" + (contador -1) + " + " + "V" + contador + ": ");
        //vector2.imprimirSuma();
      }
      
      contador = contador + 1; 
      
    }
    while (vector2.x != 0 && vector2.y != 0);
    
    
    
    
  }
  
  public boolean leer()
  {
    
    Scanner teclado = new Scanner(System.in);
    
    System.out.print("X: ");
    x = teclado.nextDouble();
    
    System.out.print("Y: ");
    y = teclado.nextDouble();
    
    System.out.println();
    
    if (x == 0.0 && y == 0.0)
      return false;
    else
      return true;
  }
  
  public void imprimir()
  {
    System.out.printf("(x,y) = (%.2f, %.2f);", x, y);
    System.out.printf("(r, angulo) = (%.2f, %.2f)", calcularR(x, y),calcularAngulo(x, y));
    System.out.println();
  }
  
  public double calcularR(double x, double y)
  {
    return Math.sqrt((x*x) + (y*y));
  }
  
  public double calcularAngulo(double x, double y)
  {
    return Math.atan2(y,x);
  }
  
  public Vector sumarVectores(Vector otro)
  {
    Vector resultado = new Vector();
    resultado.x = this.x + otro.x;
    resultado.y = this.y + otro.y;
    
    return resultado;
  }
 // public void imprimirSuma()
  //{
   // System.out.printf("(x,y) = (%.2f, %.2f);", vector1.sumarVectores(vector2));
   // System.out.printf("(r, angulo) = (%.2f, %.2f)", calcularR(x, y),calcularAngulo(x, y));
    //System.out.println();
  //}
  
  
  
}
