lListStudent students = new ArrayListStudent();
創新互聯服務項目包括西夏網站建設、西夏網站制作、西夏網頁制作以及西夏網絡營銷策劃等。多年來,我們專注于互聯網行業,利用自身積累的技術優勢、行業經驗、深度合作伙伴關系等,向廣大中小型企業、政府機構等提供互聯網行業的解決方案,西夏網站推廣取得了明顯的社會效益與經濟效益。目前,我們服務的客戶以成都為中心已經輻射到西夏省份的部分城市,未來相信會繼續擴大服務區域并繼續獲得客戶的支持與信任!
BufferedReader br = new BufferedReader(new FileReader("D:\student.txt"));
String tmpStr = br.readLine();
while(tmpStr != null){
int firstIndex = tmpStr.indexOf(" ");
int secondIndex = tmpStr.indexOf(" ",firstIndex + 1);
int thirdIndex = tmpStr.indexOf(" ", secondIndex + 1);
int forthIndex = tmpStr.indexOf(" ", thirdIndex + 1);
Integer stuId = Integer.parseInt(tmpStr.substring(0,firstIndex));
String stuName = tmpStr.substring(firstIndex + 1,secondIndex);
Integer stuYW = Integer.parseInt(tmpStr.substring(secondIndex + 1,thirdIndex));
Integer stuSX = Integer.parseInt(tmpStr.substring(thirdIndex + 1,forthIndex));
Integer stuYY = Integer.parseInt(tmpStr.substring(forthIndex + 1));
Student student = new Student();
student.setStuId(stuId);
student.setStuName(stuName);
student.setStuYW(stuYW);
student.setStuSX(stuSX);
student.setStuYY(stuYY);
students.add(student);
tmpStr.readLine();
}
//創建一個學生實體類 封裝stuId stuName stuYW stuSx stuYY 這5個屬性。。。
//已經幫你把數據拆分出來 并以Student 對象的形式放入集合中了 接下來 給分吧 哇咔咔
完成了,希望能幫到你
剛開始會叫你輸入編號選擇功能
import java.io.*;
public class student {
public static void main(String args[]) throws IOException{
int[] stud = {77,99,55,46,82,75,65,31,74,85};
System.out.println("請選擇功能:");//輸入編號選擇功能
System.out.println("1、輸入學號,查詢該學生成績:");
System.out.println("2、輸入成績,查詢學生學號:");
System.out.println("3、輸入學號,刪除該學生成績");
System.out.println("請選擇編號:");
BufferedReader td = new BufferedReader(new InputStreamReader(System.in));
String temp = td.readLine();
int choice = Integer.valueOf(temp);
if(choice == 1){//一為查詢學生成績
System.out.println("請輸入學號:");
BufferedReader sd = new BufferedReader(new InputStreamReader(System.in));
String temp_sd = sd.readLine();
int No = Integer.valueOf(temp_sd);
System.out.print("學號為 "+No+" 的學生成績為: " + stud[No-1] +"分");
}
if(choice == 2){//二為查詢學生編號
System.out.println("請輸入成績:");
BufferedReader sd = new BufferedReader(new InputStreamReader(System.in));
String chengji = sd.readLine();
int temp_cj = Integer.valueOf(chengji);
for(int i=0;istud.length;i++){
if(temp_cj == stud[i]){
System.out.print("成績為 "+ temp_cj+ "的學生的學號為: "+(i+1));
}
}
}
if(choice == 3){//三為刪除操作
System.out.println("請輸入學號:");
BufferedReader sd = new BufferedReader(new InputStreamReader(System.in));
String temp_sd = sd.readLine();
int No = Integer.valueOf(temp_sd);
stud[No-1]=0;//直接賦值為0,不刪除學生
System.out.print("學號為 "+No+" 的學生成績為: " + stud[No-1] +"分");
}
}
}
用java寫的話,可以用List來實現學生管理系統:\x0d\x0a首先,管理系統是針對學生對象的,所以我們先把學生對象就寫出來:\x0d\x0apackage bean;\x0d\x0apublic class Student {\x0d\x0a String name;\x0d\x0a String studentId;\x0d\x0a String sex;\x0d\x0a int grade;\x0d\x0a public Student(String name,String studentId,String sex,int grade){\x0d\x0a this.name= name;\x0d\x0a this.studentId= studentId;\x0d\x0a this.sex = sex;\x0d\x0a this.grade = grade; \x0d\x0a }\x0d\x0a public int getGrade(){\x0d\x0a return grade;\x0d\x0a }\x0d\x0a public String getName(){\x0d\x0a return name;\x0d\x0a }\x0d\x0a public String getSex(){\x0d\x0a return sex;\x0d\x0a }\x0d\x0a public void setGrade(int g){\x0d\x0a this.grade = g;\x0d\x0a }\x0d\x0a public String getStudentId(){\x0d\x0a return studentId;\x0d\x0a }\x0d\x0a}\x0d\x0a這里面定義了一些得到當前學生對象數據的一些get方法,和成績修改的set方法,代碼很簡單,就不做詳細的解答。\x0d\x0a就下來就是我們的正文了。\x0d\x0a雖然我們暫時不用swing來做界面,但是總得要看的過去吧,所以,先做了一個比較簡單的界面:\x0d\x0a System.out.println("***************");\x0d\x0a System.out.println("*歡迎來到學生管理系統 *");\x0d\x0a System.out.println("*1:增加學生 *");\x0d\x0a System.out.println("*2:刪除學生 *");\x0d\x0a System.out.println("*3:修改成績 *");\x0d\x0a System.out.println("*4:查詢成績 *");\x0d\x0a System.out.println("***************");\x0d\x0a System.out.println("您想選擇的操作是:");\x0d\x0a這里可以看到,我們的是用一個1234來選擇項目,說以不得不講一下Java如何獲取到鍵盤所輸入的數據---------Scanner ,要使用這個,首先需要import進來一個包:\x0d\x0a例如這里:\x0d\x0aimport java.util.*;\x0d\x0a之后的兩行代碼搞定輸入:\x0d\x0aScanner sc = new Scanner(System.in);\x0d\x0a int choice = sc.nextInt();\x0d\x0a接下來就是各個功能的實現:\x0d\x0a\x0d\x0apackage test;\x0d\x0aimport java.util.*;\x0d\x0aimport bean.Student;\x0d\x0apublic class Manager {\x0d\x0a static List StudentList = new LinkedList();\x0d\x0a public static void main(String[] agrs){\x0d\x0a select(StudentList); \x0d\x0a }\x0d\x0a private static void select(List StudentList ){\x0d\x0a System.out.println("***************");\x0d\x0a System.out.println("*歡迎來到學生管理系統 *");\x0d\x0a System.out.println("*1:增加學生 *");\x0d\x0a System.out.println("*2:刪除學生 *");\x0d\x0a System.out.println("*3:修改成績 *");\x0d\x0a System.out.println("*4:查詢成績 *");\x0d\x0a System.out.println("***************");\x0d\x0a System.out.println("您想選擇的操作是:");\x0d\x0a Scanner sc = new Scanner(System.in);\x0d\x0a int choice = sc.nextInt(); \x0d\x0a switch(choice){\x0d\x0a //增加學生\x0d\x0a case 1:\x0d\x0a System.out.print("請輸入學生的姓名:");\x0d\x0a Scanner Sname = new Scanner(System.in);\x0d\x0a String name = Sname.nextLine();\x0d\x0a System.out.print("請輸入學生的性別:");\x0d\x0a Scanner Ssex = new Scanner(System.in);\x0d\x0a String sex = Ssex.nextLine();\x0d\x0a System.out.print("請輸入學生的學號:");\x0d\x0a Scanner SId = new Scanner(System.in);\x0d\x0a String studentId = SId.nextLine();\x0d\x0a System.out.print("請輸入學生的成績:");\x0d\x0a Scanner Sgrade = new Scanner(System.in);\x0d\x0a int grade = Sgrade.nextInt();\x0d\x0a StudentList.add(new Student(name,studentId,sex,grade));\x0d\x0a System.out.println("添加成功!!!!!");\x0d\x0a select(StudentList);\x0d\x0a break;\x0d\x0a //刪除學生成績\x0d\x0a case 2:\x0d\x0a System.out.print("請告訴我需要刪除學生的學號:");\x0d\x0a Scanner Sid = new Scanner(System.in);\x0d\x0a String SstudentId = Sid.nextLine();\x0d\x0a boolean isfindDelete = false;\x0d\x0a for (int i = 0; i
回答于?2022-11-16
文章題目:java學員管理系統代碼 javaweb學生管理系統源碼
文章轉載:http://m.kartarina.com/article48/dodspep.html
成都網站建設公司_創新互聯,為您提供全網營銷推廣、網站設計、網站內鏈、微信公眾號、網站設計公司、做網站
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯