小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

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

 文化龍鄉(xiāng) 2019-11-12
學(xué)生成績管理系統(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, '輸入有誤,請重新輸入(1-7)');

}

}

}

public static boolean login(){//登錄

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

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

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

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

return true;

}

else{

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

}

}

return false;

}

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

String codeStr = JOptionPane.showInputDialog(null,'請輸入學(xué)號');

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

double grade = Double.parseDouble(JOptionPane.showInputDialog(null,'請輸入成績'));

number[num] = codeStr;

name[num] = nameStr;

score[num] = grade;

num++;

}

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

String str = '學(xué)號 姓名 成績\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, '請輸入姓名');

int index = -1;

for (int i=0; i

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

index = i;

}

}

if (index == -1){

JOptionPane.showMessageDialog(null, '沒有找到該學(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é)號 姓名 成績\n';

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

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,'沒有找到該學(xué)生');

}

else{

JOptionPane.showMessageDialog(null,str);

}

}

public static void updateStudent(){//修改

int index = -1;

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

for (int i=0; i

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

index = i;

String strNum = JOptionPane.showInputDialog(null,'請輸入學(xué)號');

number[i] = strNum;

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

name[i] = strName;

double s = Double.parseDouble(JOptionPane.showInputDialog(null,'請輸入成績'));

score[i] = s;

}

}

if (index == -1){

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

return;

}

String str = '學(xué)號 姓名 成績\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();

}

}

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

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多