import java.util.Scanner;

public class Examen01
{
  public static void main (String args[])
  {
    Scanner teclado = new Scanner(System.in);
    
    System.out.print("Tablas de operadores");
  
    for(int fin=1; fin!=2; )
    {
      System.out.print("\nOperador [ + | - | * | / | % | S(Salir)");
      teclado.skip("[\n\t\r ]*");
      String ope = teclado.nextLine();
      if (ope.equalsIgnoreCase("S"))
      {System.out.print("Fin");
        ++fin;}
      else 
      {
        {
          System.out.print("Valor minimo: ");
          double min = teclado.nextDouble();
          System.out.print("Valor maximo: ");
          double max = teclado.nextDouble();
          double inc=0;
          for(; inc<=0;)
          {
            System.out.print("Incremento: ");
            inc = teclado.nextDouble();
            if (inc<=0) System.err.println("El incremento debe ser positivo");
          }
          
          
          //SUMA
          if(ope.equals("+"))
          {
            System.out.printf( "%4s %2s" , "+", "|");
            for (double fila=min; fila<=max; fila=fila+inc)
            {
              System.out.printf("%6.1f",fila);}
            System.out.print("\n------|");
            for(double columna=min; columna<=max; columna=columna+inc)
            { 
              System.out.printf("\n %4.1f %1s",columna, "|");
              for (double sum=min; sum<=max; sum=sum+inc)
              { 
                double res= sum+columna;
                System.out.printf("%6.1f",res);}}
            System.out.println();
          }
          
          //RESTA
          if(ope.equals("-"))
          {
            System.out.printf( "%4s %2s" , "-", "|");
            for (double fila=min; fila<=max; fila=fila+inc)
            {
              System.out.printf("%6.1f",fila);}
            System.out.print("\n------|");
            for(double columna=min; columna<=max; columna=columna+inc)
            { 
              System.out.printf("\n %4.1f %1s",columna, "|");
              for (double resta=min; resta<=max; resta=resta+inc)
              { 
                double res= resta-columna;
                System.out.printf("%6.1f",res);}}
            System.out.println();
          }
          
          //MULTIPLICACION
          if(ope.equals("*"))
          {
            
            System.out.printf( "%4s %2s" , "*", "|");
            for (double fila=min; fila<=max; fila=fila+inc)
            {
              System.out.printf("%6.1f",fila);}
            System.out.print("\n------|");
            for(double columna=min; columna<=max; columna=columna+inc)
            { 
              System.out.printf("\n %4.1f %1s",columna, "|");
              for (double mult=min; mult<=max; mult=mult+inc)
              { 
                double res= mult*columna;
                System.out.printf("%6.1f",res);}}
            System.out.println();
          }
          
          //DIVISION
          if(ope.equals("/"))
          {
            System.out.printf( "%4s %2s" , "/", "|");
            for (double fila=min; fila<=max; fila=fila+inc)
            {
              System.out.printf("%6.1f",fila);}
            System.out.print("\n------|");
            for(double columna=min; columna<=max; columna=columna+inc)
            { 
              System.out.printf("\n %4.1f %1s",columna, "|");
              for (double div=min; div<=max; div=div+inc)
              { 
                double res= div/columna;
                System.out.printf("%6.1f",res);}}
            System.out.println();
          }
          
          //MODULO
          if(ope.equals("%"))
          {
            System.out.printf( "%4s %2s" , "%", "|");
            for (double fila=min; fila<=max; fila=fila+inc)
            {
              System.out.printf("%6.1f",fila);}
            System.out.print("\n------|");
            for(double columna=min; columna<=max; columna=columna+inc)
            { 
              System.out.printf("\n %4.1f %1s",columna, "|");
              for (double mod=min; mod<=max; mod=mod+inc)
              { 
                double res= mod%columna;
                System.out.printf("%6.1f",res);}}
          }
        }
      }
    }
  }
} //class
