本文為大家分享了java實(shí)現(xiàn)學(xué)生成績(jī)錄入系統(tǒng),供大家參考,具體內(nèi)容如下
成都創(chuàng)新互聯(lián)公司專注于建華網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗(yàn)。 熱誠(chéng)為您提供建華營(yíng)銷型網(wǎng)站建設(shè),建華網(wǎng)站制作、建華網(wǎng)頁(yè)設(shè)計(jì)、建華網(wǎng)站官網(wǎng)定制、小程序定制開(kāi)發(fā)服務(wù),打造建華網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供建華網(wǎng)站排名全網(wǎng)營(yíng)銷落地服務(wù)。
1.學(xué)生類,包括學(xué)生的姓名和各科成績(jī)
public class Score { public String name; public double EnglishGrade, MathGrade,phyicalGrade, chemicalGrade,biologicalGrade; Score() { } public Score(String name,double EnglishGrade, double MathGrade,double phyicalGrade, double chemicalGrade,double biologicalGrade){ this.name = name; this.EnglishGrade = EnglishGrade; this.MathGrade = MathGrade; this.phyicalGrade = phyicalGrade; this.chemicalGrade = chemicalGrade; this.biologicalGrade = biologicalGrade; } }
2.對(duì)學(xué)生類進(jìn)行設(shè)置,包括設(shè)置查找等
package score; public class ScoreZip { Score[] S = new Score[5]; public void setData(Score name, int index) {//添加成績(jī)類到成績(jī)數(shù)組中 S[index] = name; } public Score[] getData() { //返回學(xué)生數(shù)組 return S; } public Score SerchData(String name) { //查找學(xué)生各科成績(jī) for (int index = 0; index < S.length; index++) { if (name !=null && S[index] != null ) if (S[index].name.equals(name)){ return S[index]; } } return null; } }
3.學(xué)生成績(jī)錄入及學(xué)生成績(jī)清單
package score; import java.util.Scanner; public class ScoreZip2 { public static void main(String[] arr) { Scanner Sc = new Scanner(System.in); ScoreZip Sr = new ScoreZip(); for (int i = 0; i < 5; i++) { //這里定義長(zhǎng)度為五的學(xué)生成績(jī)表 System.out.println("輸入學(xué)生姓名:"); String name = Sc.next(); if (name.equals("n")) { break; } System.out.println("英語(yǔ)分?jǐn)?shù):"); double English = Sc.nextDouble(); System.out.println("數(shù)學(xué)分?jǐn)?shù):"); double Math = Sc.nextDouble(); System.out.println("物理分?jǐn)?shù):"); double Physical = Sc.nextDouble(); System.out.println("化學(xué)分?jǐn)?shù):"); double Chemical = Sc.nextDouble(); System.out.println("生物分?jǐn)?shù):"); double Biology = Sc.nextDouble(); Score s = new Score(name, English,Math,Physical,Chemical,Biology); Sr.setData(s, i); } System.out.println("=========================================" + "學(xué)生成績(jī)表======================================"); System.out.println("姓名\t\t英語(yǔ)成績(jī)\t\t數(shù)學(xué)成績(jī)\t\t物理成績(jī)\t\t化學(xué)成績(jī)\t\t生物成績(jī)"); Score[] b = Sr.getData(); for (Score S : b) { if (S == null) { break; } System.out.println(S.name + "\t\t" + S.EnglishGrade+"\t\t"+S.MathGrade +"\t\t"+S.phyicalGrade+"\t\t"+S.chemicalGrade+"\t\t"+S.biologicalGrade); } System.out.println("是否查找學(xué)生成績(jī)? 是Y 否N"); String flag = Sc.next(); if(flag.equals("Y")){ System.out.println("輸入要查找的學(xué)生名:"); String name = Sc.next(); Score S = Sr.SerchData(name); if (S == null) { System.out.println("對(duì)不起,沒(méi)有此學(xué)生名"); } else { double mg = S.MathGrade; double eg = S.EnglishGrade; double pg = S.phyicalGrade; double cg= S.chemicalGrade; double bg = S.biologicalGrade; double submit = mg+eg+pg+cg+bg; System.out.println("要查找的學(xué)生為:" + name + "\n數(shù)學(xué)成績(jī)?yōu)?" + mg + "\n英語(yǔ)成績(jī)?yōu)?" + eg+ "\n物理成績(jī)?yōu)?" + pg+ "\n化學(xué)成績(jī)?yōu)?" + cg + "\n生物成績(jī)?yōu)?" + bg+ "\n總成績(jī)成績(jī)?yōu)?" + submit); } } } }
結(jié)果圖:
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持創(chuàng)新互聯(lián)。