package mef2;

import java.util.Scanner;

public class Metodos {

    public double leerReal(String mensaje) {
        double numero = 0;
        mostrar(mensaje);
        Scanner captura = new Scanner(System.in);
        numero = captura.nextDouble();
        return numero;
    }

    public void mostrar(String mensaje) {
        System.out.println(" " + mensaje);
    }

    public int leerEntero(String mensaje) {
        int numero = 0;
        mostrar(mensaje);
        Scanner captura = new Scanner(System.in);
        numero = captura.nextInt();
        return numero;
    }

    public String leerCadena(String mensaje) {
        String cadena = "";
        mostrar(mensaje);
        Scanner captura = new Scanner(System.in);
        cadena = captura.nextLine();
        return cadena;
    }

    public static boolean Constante(String C) {
        boolean resultado;
        try {
            Integer.parseInt(C);
            resultado = true;
        } catch (Exception e) {
            resultado = false;
        }
        return resultado;
    }
    
    public static String Variables_repetidas(String Valor) {
        String[] Caracteres = Valor.replaceAll("\n", "").replaceAll("\t", "").split(" ");
        String Caracteres1 = "";
        int m = Caracteres.length;
        for (int i = 0; i < Caracteres.length; i++) {
            for (int j = 0; j < Caracteres.length - 1; j++) {
                if (i != j) {
                    if (Caracteres[i].equals(Caracteres[j])) {
                        Caracteres[i] = "";
                    }
                }
            }
        }
        for (int h = 0; h <= m - 1; h++) {    
            if (Caracteres[h] != "" && Caracteres[h].length() > 0 ) {
            String p = Caracteres[h].substring(0,1);
                if (Constante(p) == false) {
                Caracteres1 = Caracteres1 + Caracteres[h] + " ";
                Caracteres1 = Caracteres1 + "\n";
                }
            }
        }
        return Caracteres1;
    }

    public static String Constantes_repetidas(String Valor) {
        String[] Caracteres = Valor.replaceAll("\n", "").replaceAll("\t", "").split(" ");
        String Caracteres1 = "";
        int m = Caracteres.length;
        for (int i = 0; i < Caracteres.length; i++) {
            for (int j = 0; j < Caracteres.length - 1; j++) {
                if (i != j) {
                    if (Caracteres[i].equals(Caracteres[j])) {
                        Caracteres[i] = "";
                    }
                }
            }
        }
        for (int h = 0; h <= m - 1; h++) {
            if (Caracteres[h] != "") {
                Caracteres1 = Caracteres1 + Caracteres[h] + " ";
                Caracteres1 = Caracteres1 + "\n";
            }
        }
        return Caracteres1;
    }
}
