深夜成人在线,chinese国产一区二区,欧美精品乱码,日韩欧美在线视频免费观看,国产午夜不卡,日韩av影院在线,五月天婷婷国产精品

軟題庫(kù) 學(xué)習(xí)課程
當(dāng)前位置:信管網(wǎng) >> 在線考試中心 >> 試題查看
試題題型【分析簡(jiǎn)答題】
試題內(nèi)容

閱讀以下說(shuō)明和Java代碼,將應(yīng)填入 (n) 處的語(yǔ)句或語(yǔ)句成分寫在答題紙的對(duì)應(yīng)欄內(nèi)。
【說(shuō)明】
某數(shù)據(jù)文件students.txt的內(nèi)容為100名學(xué)生的學(xué)號(hào)和成績(jī),下面的程序?qū)⑽募械臄?shù)據(jù)全部讀入對(duì)象數(shù)組,按分?jǐn)?shù)從高到低進(jìn)行排序后選出排名前30%的學(xué)生。
【Java代碼】
import java.io.*;

class Student {
private String sNO;       //學(xué)號(hào)
private int Credit;  //分?jǐn)?shù)
public int getCredit( ){
return Credit;
}
public String toString() {
return "sNO = " + this.sNO + ", Credit = " + this.Credit;
}

Student(String sNO, int Credit){
(1)   = sNO;
(2)   = Credit;
}
}

public class SortStudent {
void sort(Student[ ] s) { //Sort the array s[ ] in descending order of
Credit
for (int i = 0; i < s.length-1; i++) {
for (int .j = i+1; j < s.length; j++) {
if (s[i].  (3)  < s[j]. (4) ) {
Student tmp = s[i];
s[i] = s[j];
s[j] = tmp;
}
}
}
}


public static void main(String argv[ ]) {
Student[ ] testStudent = new Student[size];
try {

BufferedReader in = new BufferedReader(new FileReader
("students.txt"));
boolean done = false;

int i = 0;
while (!done) {
String s = in.readLine();   //每次讀取一個(gè)學(xué)生的學(xué)號(hào)和成績(jī)
if (s != null) {
String tmp[ ] = s.split(",");
testStudent[i++] =   (5)  (tmp[0], Integer.parseInt
(tmp[1]));
} else
done = true;
}
in.close();
(6)   = new SortStudent();
ss.sort(testStudent);
System.out.println("top 30%:");
for (int j = 0; j < size * 0.3; j++)
System.out.println(testStudent[j]);
} catch (IOException e) {
System.out.println("io error!");
}catch (NumberFormatException e) {
System.out.println("not a number!");
}
}

(7)   int size = 100; //學(xué)生總數(shù)
}

查看答案

相關(guān)試題