日韩黑丝制服一区视频播放|日韩欧美人妻丝袜视频在线观看|九九影院一级蜜桃|亚洲中文在线导航|青草草视频在线观看|婷婷五月色伊人网站|日本一区二区在线|国产AV一二三四区毛片|正在播放久草视频|亚洲色图精品一区

分享

學(xué)生成績(jī)管理系統(tǒng)(小程序代碼)

 文化龍鄉(xiāng) 2019-11-12
學(xué)生成績(jī)管理系統(tǒng)(小程序代碼)

package day1;

import javax.swing.JOptionPane;

public class day1HomeWork {

public static String[] number = new String[20];

public static String[] name = new String[20];

public static double[] score = new double[20];

public static int num = 0;

public static void main(String[] args) {

// TODO Auto-generated method stub

JOptionPane.showMessageDialog(null,'歡迎光臨');

boolean flag = login();

if (flag == false){

JOptionPane.showMessageDialog(null,'非法用戶');

System.exit(-1);

}

while (true){

String input = JOptionPane.showInputDialog(null,'1、添加\n2、顯示\n'

+ '3、刪除\n4、查找\n5、修改\n6、排序\n7、退出');

char ch = input.toCharArray()[0];

switch (ch){

case '1':

addStudent();

break;

case '2':

showStudent();

break;

case '3':

deleteStudent();

break;

case '4':

queryStudent();

break;

case '5':

updateStudent();

break;

case '6':

sortStudent();

break;

case '7':

JOptionPane.showMessageDialog(null,'謝謝使用');

System.exit(-1);

break;

default:

JOptionPane.showMessageDialog(null, '輸入有誤,請(qǐng)重新輸入(1-7)');

}

}

}

public static boolean login(){//登錄

for (int i=0; i<3; i++){

String userName = JOptionPane.showInputDialog(null,'請(qǐng)輸入用戶名');

int pwd = Integer.parseInt(JOptionPane.showInputDialog(null,'請(qǐng)輸入密碼'));

if (userName.equals('lwz') && pwd == 1992){

return true;

}

else{

JOptionPane.showMessageDialog(null,'用戶名或密碼錯(cuò)誤');

}

}

return false;

}

public static void addStudent(){//添加學(xué)生信息

String codeStr = JOptionPane.showInputDialog(null,'請(qǐng)輸入學(xué)號(hào)');

String nameStr = JOptionPane.showInputDialog(null,'請(qǐng)輸入姓名');

double grade = Double.parseDouble(JOptionPane.showInputDialog(null,'請(qǐng)輸入成績(jī)'));

number[num] = codeStr;

name[num] = nameStr;

score[num] = grade;

num++;

}

public static void showStudent(){//顯示學(xué)生信息

String str = '學(xué)號(hào) 姓名 成績(jī)\n';

for (int i=0; i

// if (number[i] == null)

// continue;

str += number[i]+' '+name[i]+' '

+score[i]+'\n';

}

JOptionPane.showMessageDialog(null,str);

}

public static void deleteStudent(){//刪除學(xué)生信息

String input = JOptionPane.showInputDialog(null, '請(qǐng)輸入姓名');

int index = -1;

for (int i=0; i

if (name[i].equals(input)){

index = i;

}

}

if (index == -1){

JOptionPane.showMessageDialog(null, '沒(méi)有找到該學(xué)生');

return;

}

for (int i=index; i

number[i] = number[i+1];

name[i] = name[i+1];

score[i] = score[i+1];

}

num--;

showStudent();

}

public static void queryStudent(){//查找

int index = -1;

String str = '學(xué)號(hào) 姓名 成績(jī)\n';

String input = JOptionPane.showInputDialog(null,'請(qǐng)輸入姓名');

for (int i=0; i

if (name[i].equals(input)){

index = i;

str += number[i]+' '+name[i]+' '+score[i]+'\n';

}

}

if (index == -1){

JOptionPane.showMessageDialog(null,'沒(méi)有找到該學(xué)生');

}

else{

JOptionPane.showMessageDialog(null,str);

}

}

public static void updateStudent(){//修改

int index = -1;

String input = JOptionPane.showInputDialog(null,'請(qǐng)輸入姓名');

for (int i=0; i

if (name[i].equals(input)){

index = i;

String strNum = JOptionPane.showInputDialog(null,'請(qǐng)輸入學(xué)號(hào)');

number[i] = strNum;

String strName = JOptionPane.showInputDialog(null,'請(qǐng)輸入姓名');

name[i] = strName;

double s = Double.parseDouble(JOptionPane.showInputDialog(null,'請(qǐng)輸入成績(jī)'));

score[i] = s;

}

}

if (index == -1){

JOptionPane.showMessageDialog(null, '沒(méi)有找到該學(xué)生');

return;

}

String str = '學(xué)號(hào) 姓名 成績(jī)\n';

for (int i=0; i

str += number[i]+' '+name[i]+' '+score[i]+'\n';

}

JOptionPane.showMessageDialog(null, str);

}

public static void sortStudent(){//排序

for (int i=0; i

for (int j=i+1; j

if (score[i] < score[j]){

String s = number[i];

number[i] = number[j];

number[j] = s;

String n = name[i];

name[i] = name[j];

name[j] = n;

double temp = score[i];

score[i] = score[j];

score[j] = temp;

}

}

}

showStudent();

}

}

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多