String with some characters in asterisks

0

I need to enter a line of text of the style:

[email protected]

And to return:

p**********[email protected]



    public static void main(String[] args) {
    Scanner in = new Scanner(System.in);

    String email;
    int longitud = Integer.MIN_VALUE;

    System.out.println("Ingrese su email");
    email = in.nextLine();
    longitud = email.length();
    
asked by user10408376 09.10.2018 в 21:19
source

1 answer

0

I'm staying. Thanks

    import java.util.Scanner;

    public class Tarea4 {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        String email;
        int longitudPrimeraParte = Integer.MIN_VALUE;
        System.out.println("Ingrese su email");
        email = in.nextLine();

        String primeraParte = email.split("@")[0];
        longitudPrimeraParte = primeraParte.length();
        String segundaParte = email.split("@")[1];

        System.out.print(primeraParte.substring(0, 1));
        for (int i = 0; i <= (longitudPrimeraParte - 2); i++) {
            System.out.print("*");
        }
        System.out.print(primeraParte.substring(longitudPrimeraParte - 1, longitudPrimeraParte)
                + "@" + segundaParte.toLowerCase());

    }

}
    
answered by 09.10.2018 / 23:20
source