为用户创建密码,包括向后写的姓氏,然后是星号,年龄,然后是星号,然后是向后写的名字

时间:2016-12-14 13:35:01

标签: java variables bluej password-encryption change-password

public static void main(String [] args)     {

    String firstName = "";
    double age =0;    
    String surname ="";
    String password ="";

   Scanner scan = new Scanner (System.in);

   System.out.println("Please enter your first name:");
   firstName= scan.nextLine();

   System.out.println("Please enter your age:");
   age=scan.nextDouble();

   System.out.println("Please enter your surname:");
   surname= scan.nextLine();

   System.out.println("Please enter your password:");
   password=scan.nextLine();

}

我是否为surnameBackwards创建另一个变量?

1 个答案:

答案 0 :(得分:0)

这样的事情:

String surnameBackwards = StringUtils.reverse(surname) + "*" + age + "*" + StringUtils.reverse(firstName)