未分类题

阅读以下说明和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('该用户不存在!');
}
}
}

A.getPass());


【参考答案】

(1) getUser (2) getPass (3) name.equals('end') (4) break (5)......

(↓↓↓ 点击下方‘点击查看答案’看完整答案 ↓↓↓)
热门 试题

未分类题
阅读以下程序说明和C++程序,将程序段中(1)~(5)空缺处的语句填写完整。【说明】以下【C++程序】实现一个简单的小型复数类MiniComplex,该复数类能进行输入、输出、复数的加法、减法、乘法和除法运算,还可以进行复数的相等比较。【C++程序】ifndef H_MiniComplexdefine H_MiniComplexinclude <iostream>using namespace std;class MiniComplex{public: 重载流插入和提取运算符(1) ostream&operator<<(ostream &osObject,const MiniComplex&complex){osObject<<'('<<complex.realPart<<'+'<<complex.imagPart<<'i'<<')';return osObject;}(2) istream&operator>>(istream&isObject, MiniComplex&complex){char ch;isObject >>complex.realPart>>ch>>complex.imagPart>>ch;return isObject;}MiniComplex(double real=0,double imag=0); 构造函数MiniComplex operator+(const MiniComplex&otherComplex)const; 重载运算符+MiniComplex operator-(const MiniComplex&otherComplex)const; 重载运算符-MiniComplex operator*(const MiniComplex&otherComplex)const; 重载运算符*MiniComplex operator (const MiniComplex&otherComplex)const; 重载运算符 bool perator==(const MiniComplex&otherComplex)const; 重载运算符==private :double (3);double imagPart;};end ifinclude 'MiniComplex.h'bool MiniComplex::operator==(const MiniComplex&otherComplex)const{return(realPart==otherComplex.realPart&&imagPart==ortherComplex.imagPart);}MiniComplex::MiniComplex(double real,double imag){realPart== real; imagPart==imagPart;}MiniComplex MiniComplex::operator+(const MiniComplex&otherComplex)const{MiniComplex temp;temp.realPart = realPart+ortherComplex. realPart;temp.imagPart = imagPart +ortherComplex. imagPart;return temp;}(4){ MiniComplex temp;temp.realPart= realPart-ortherComplex. realPart;temp.imagPart = imagPart-ortherComplex. imagPart;return temp;}MiniComplex MiniComplex::operator*(const MiniComplex&otherComplex)const{MiniComplex temp;temp.realPart = (realPart*ortherComplex. realPart)-(imagPart *ortherComplex.imagPart);temp.imagPart = (realPart*ortherComplex. imagPart)+(imagPart *ortherComplex.realPart);return temp;}MiniComplex MiniComplex::operator (const MiniComplex&otherComplex)const{MiniComplex temp;float tt;tt=1 (ortherComplex.realPart*ortherComplex.realPart+ortherComplex.imagPart *ortherComplex. imagPart);temp.realPart=((realPart*ortherComplex, realPart)+(imagPart *ortherComplex. imagPart))*tt;temp.imagPart =((imagPart *ortherComplex. realPart)-(realPart*ortherComplex. imagPart))*tt;return temp;}include <iostream>include <MiniComplex.h>using namespace std;int main(){MiniComplex numl(23, 34),num2(56, 35);cout<<'Initial Value of num1='<<num1<<' n Initial Value of num2='<<num2<<end1;cout<<num1<<'+'<<num2<<'='<<num1+num2<<end1; 使用重载的加号运算符cout<<num1<<'-'<<num2<<'='<<num