+ 1

Java scanner package

Write a Java Program That prompts the user to enter a password and displays it back in the console window. The displayed password should be the entered password halved with the full password total number of characters added at the end. >> who can solve this question for me with explanation !

4th Oct 2018, 12:08 AM
Yaser
Yaser - avatar
3 Respostas
+ 1
import java.util.Scanner; Scanner in = new Scanner(system.in); System.out.println("enter password"); String s = in.nextLine(); //scans the input int a = s.length(); //original password length String b =s.substring(0, a/2); //get the half password System.out.println("your password is" + b +""+ a);
4th Oct 2018, 12:39 AM
nikos
nikos - avatar
0
please enter the password: abcd your password is: ab4 the output must show as the above
4th Oct 2018, 12:10 AM
Yaser
Yaser - avatar
0
thanks a lot am gonna try it
4th Oct 2018, 12:40 AM
Yaser
Yaser - avatar