网友您好, 请在下方输入框内输入要搜索的题目:
阅读以下说明和java代码,将应填入(n)处的字句写在对应栏内。
[说明]
本程序中预设了若干个用户名和口令。用户输入正确的用户名后,可以查找对应的口令,一旦输入结束标记“end”,程序结束。
[Java代码]
import java. io. *:
public class User {
public String user;
public Siring pass;
public User() { }
public User( String u,String p) {
user=u;
pass=p;
}
public String (1) () { return this. user; }
public String (2) () { return this. pass; }
public static void main(String[] args) {
User ua[]={new User("Li","123456"), new User("wang","654321"),
new User("Song","666666")};
while(true) {
InputStreamReader reader = new InputStreamReader(System. in);
BufferedReader inpul = new BnfferedReader(reader);
System. out. print("Enter your name:");
String name = null;
try { name = input. readLine();}
catch (IOException ex) {}
if((3)) break;
int i;
for (i=0;i<3;i++) {
if (name. equals(ua[i]. getUser())){
System. out. println("密码:"+ua[i].getPass());
(4);
}
}
if ((5)) System. out. println("该用户不存在!");
}
}
}
参考答案