import java.util.Arrays;
import java.util.Scanner;
public class StudentScore {
static Scanner input = new Scanner(System.in);\
//學(xué)生個數(shù)
static String names[] = new String[2];
//課程數(shù)量
static int score[][] = new int[names.length][5];
private static Scanner scan;
/**
* names[]長度
*/
static int LEN = names.length;
/**
* score[]長度
*/
static int SLEN = score.length;
public static void main(String args[]) {
welcome();
options();
}
public static void welcome() {
System.out.println("請輸入一個選項:");
System.out.print("1`輸入學(xué)生成績 ");
System.out.print("2`顯示全部學(xué)生成績 ");
System.out.println("3`查詢學(xué)生成績");
System.out.print("4`求學(xué)生總分 ");
System.out.print("5`顯示最高分 ");
System.out.println("6`顯示最低分");
System.out.print("7`查看平均分 ");
System.out.println("8`退出系統(tǒng)");
}
public static void options() {
System.out.println("請輸入您所需查詢的選項:");
int num = input.nextInt();
switch (num) {
case 1:
entryResults();
welcome();
options();
break;
case 2:
studentInfo();
options();
break;
case 3:
inquireInfo();
welcome();
options();
break;
case 4:
totalScore();
welcome();
options();
break;
case 5:
maxScore();
welcome();
options();
break;
case 6:
minScore();
welcome();
options();
break;
case 7:
avgScore();
welcome();
options();
break;
case 8:
System.out.println("bye!");
System.exit(0);
break;
default:
System.out.println("輸入有誤,請重新輸入:");
welcome();
options();
}
}
public static void entryResults() {
for (int i = 0; i < LEN; i++) {
System.out.println("請輸入第" + (i + 1) + "個學(xué)生姓名");
names[i] = input.next();
}
for (int i = 0; i < SLEN; i++) {
for (int j = 0; j < score[i].length; j++) {
System.out.println("請錄入" + names[i] + "的" + getCoursName(j) + "成績");
score[i][j] = input.nextInt();
}
}
System.out.println("錄入完成!");
}
public static String getCoursName(int i) {
switch (i) {
case 0:
return "數(shù)學(xué)";
case 1:
return "英語";
case 2:
return "計算機(jī)";
case 3:
return "體育";
case 4:
return "語文";
default:
return "無";
}
}
public static void studentInfo() {
System.out.println("顯示所有學(xué)生信息:");
System.out.println("姓名\t數(shù)學(xué)\t英語\t計算機(jī)\t體育\t語文");
for (int i = 0; i < LEN; i++) {
System.out.println(names[i] + "\t");
for (int j = 0; j < score[i].length; j++) {
System.out.println(score[i][j] + "\t");
}
}
}
public static void inquireInfo() {
System.out.println("請輸入要查詢的學(xué)生姓名:");
scan = new Scanner(System.in);
String name = scan.next();
for (int i = 0; i < LEN; i++) {
if (name.equals(names[i])) {
for (int j = 0; j < 5; j++) {
System.out.println(names[i] + "的 " + getCoursName(j) + "成績是: " + score[i][j]);
}
}
}
}
public static void totalScore() {
int[] sum = new int[5];
for (int i = 0; i < LEN; i++) {
for (int j = 0; j < 5; j++) {
sum[j] += score[i][j];
}
}
for (int i = 0; i < 5; i++) {
System.out.println(getCoursName(i) + "總成績是: " + sum[i]);
}
}
public static void maxScore() {
for (int i = 0; i < SLEN; i++) {
Arrays.sort(score[i]);
System.out.println(names[i] + "最高分是 : " + score[i][score[i].length - 1]);
}
}
public static void minScore() {
for (int i = 0; i < SLEN; i++) {
Arrays.sort(score[i]);
System.out.println(names[i] + "最低分是 : " + score[i][0]);
}
}
public static void avgScore() {
int[] nums = new int[LEN];
for (int i = 0; i < SLEN; i++) {
for (int j = 0; j < score[i].length; j++) {
nums[i] += score[i][j];
}
}
for (int j = 0; j < LEN; j++) {
System.out.println(names[j] + "平均分是 : " + (nums[j] / score[j].length));
}
}
}
Java_實例_作業(yè)(控制臺學(xué)生管理系統(tǒng))
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
- 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來袄简,“玉大人腥放,你說我怎么就攤上這事÷逃铮” “怎么了秃症?”我有些...
- 文/不壞的土叔 我叫張陵,是天一觀的道長吕粹。 經(jīng)常有香客問我种柑,道長,這世上最難降的妖魔是什么匹耕? 我笑而不...
- 正文 為了忘掉前任聚请,我火速辦了婚禮,結(jié)果婚禮上稳其,老公的妹妹穿的比我還像新娘驶赏。我一直安慰自己,他們只是感情好既鞠,可當(dāng)我...
- 文/花漫 我一把揭開白布煤傍。 她就那樣靜靜地躺著,像睡著了一般嘱蛋。 火紅的嫁衣襯著肌膚如雪蚯姆。 梳的紋絲不亂的頭發(fā)上,一...
- 文/蒼蘭香墨 我猛地睜開眼铣卡,長吁一口氣:“原來是場噩夢啊……” “哼链韭!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起煮落,我...
- 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
- 正文 我和宋清朗相戀三年轿衔,在試婚紗的時候發(fā)現(xiàn)自己被綠了沉迹。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
- 正文 年R本政府宣布,位于F島的核電站底洗,受9級特大地震影響腋么,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜亥揖,卻給世界環(huán)境...
- 文/蒙蒙 一珊擂、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧费变,春花似錦未玻、人聲如沸。這莊子的主人今日做“春日...
- 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至昼激,卻和暖如春庇绽,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背橙困。 一陣腳步聲響...
- 正文 我出身青樓辟狈,卻偏偏與公主長得像,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子哼转,可洞房花燭夜當(dāng)晚...
推薦閱讀更多精彩內(nèi)容
- 【蝴蝶效應(yīng)】 蝴蝶效應(yīng):上個世紀(jì)70年代壹蔓,美國一個名叫洛倫茲的氣象學(xué)家在解釋空氣系統(tǒng)理論時說趟妥,亞馬遜雨林一只蝴蝶...
- 幫同學(xué)寫一個小程序, 通過JDBC連接MySQL數(shù)據(jù)庫, 來操作相關(guān)數(shù)據(jù)表, 并記錄和查詢信息, 沒有圖形界面, ...
- 緣起 2015年視頻設(shè)計行業(yè)不是很景氣,當(dāng)時想著怎么用業(yè)余時間做點(diǎn)別的佣蓉,于是想到了最大眾化的某寶披摄,但某寶開店一...
- 商討著方案疚膊,我正眉飛色舞,張牙舞爪地發(fā)表著自己的看法虾标,他的手機(jī)又響了寓盗。他滿臉歉疚地打斷我,接起電話:“喂夺巩,我還在談...