鍵盤錄入學生資訊按照總分排序並寫入文字檔案

2021-09-24 14:52:08 字數 1056 閱讀 2603

鍵盤錄入5個學生資訊(姓名,語文成績,數學成績,英語成績), 按照總分從高到低存入文字檔案

public class student 

public void setname(string name)

public int getchinese()

public void setchinese(int chinese)

public int getmath()

public void setmath(int math)

public int getenglish()

public void setenglish(int english)

public int sum()

}

public class scoresorttofile 

});//2: 目的地 student.txt

file destpath = new file("student.txt");

//3: 鍵盤輸入資料, 把資料封裝成學生物件, 儲存到集合中

scanner sc = new scanner(system.in);

for (int i = 0; i < 5; i++)

//5: 獲取集合中的每乙個student物件

//filewriter fw = new filewriter(destpath);

bufferedwriter bw = new bufferedwriter(new filewriter(destpath));

bw.write("學生姓名\t");

bw.write("語文成績\t");

bw.write("數學成績\t");

bw.write("英語成績\t");

bw.write("總分\t");

bw.newline();

bw.flush();

for (student s : students)

//釋放資源

bw.close();

}}

Vue指令練習例項 學生資訊錄入

很好的乙個可以感受vue.js的mvvm模型,資料和模型雙向繫結的例項練習。vue指令title fieldset fieldset input table thead style head 學生資訊錄入系統legend 姓名 span type text placeholder 請輸入姓名 v m...

哈弗曼例項輸入學生資訊

問題描述 輸入學生學號和姓名,對已有的給出提示,沒有的新增進去,最後輸出所有的奇數的學生資訊 哈弗曼類的例項 using system using system.collections.generic using system.linq using system.text using system....

學生資訊的錄入和列印,函式的封裝

內容 用鍊錶的形式完成乙個學生資訊錄入和列印 使用結構體,定義相應的資料型別 實現鍊錶的建立和插入,使用函式封裝 不同的函式放入不同的檔案中,在主函式中新增標頭檔案,然後呼叫 實現學生成績的錄入和列印 編寫主函式進行測試。使用gcc進行編譯 編寫makefile檔案,使用預定義變數和自動變數 使用g...