开学考试!!
源代碼:
package wyt;
public class ScoreInformation {
private String stunumber = " ";
private String name = " ";
private Double mathematicsscore;
private Doubleenglishiscore;
private Doublenetworkscore;
private Doubledatabasescore;
private Doublesoftwarescore;
public String getStunumber() {
return stunumber;
}
public void setStunumber(String stunumber) {
this.stunumber = stunumber;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Double getMathematicsscore() {
return mathematicsscore;
}
public void setMathematicsscore(Double mathematicsscore) {
this.mathematicsscore = mathematicsscore;
}
public Double getEnglishiscore() {
return englishiscore;
}
public void setEnglishiscore(Double englishiscore) {
this.englishiscore = englishiscore;
}
public Double getNetworkscore() {
return networkscore;
}
public void setNetworkscore(Double networkscore) {
this.networkscore = networkscore;
}
public Double getDatabasescore() {
return databasescore;
}
public void setDatabasescore(Double databasescore) {
this.databasescore = databasescore;
}
public Double getSoftwarescore() {
return softwarescore;
}
public void setSoftwarescore(Double softwarescore) {
this.softwarescore = softwarescore;
}
}
主函數:
package wyt;
import java.util.Scanner;
public class ScoreManagement {
private static ScoreInformation[] stu = new ScoreInformation[6];
static Scanner scan = new Scanner(System.in);
static int i = 0;
static boolean tag = true;
static boolean tag_1 = true;
//主類
public static void main(String[] args) {
add();
while(tag_1)
{
manu();
int a = scan.nextInt();
switch (a) {
case 1:luru();break;
case 2:xiugai();break;
case 3:jidian();break;
case 4:tag_1=false;break;
default:
break;
}
}
System.out.println("***********************************************************");
System.out.println(" 謝謝使用石家莊鐵道大學軟件工程系學生學籍管理系統 2019 版 ");
System.out.println(" 制作人:王玉曇 ");
System.out.println("***********************************************************");
}
//存入
static public void add()
{
stu[0] = new ScoreInformation();
stu[0].setStunumber("20183766");
stu[0].setName("王玉曇");
stu[1] = new ScoreInformation();
stu[1].setStunumber("20183763");
stu[1].setName("憨批凌云");
stu[2] = new ScoreInformation();
stu[2].setStunumber("20183773");
stu[2].setName("戴偉偉");
stu[3] = new ScoreInformation();
stu[3].setStunumber("20183750");
stu[3].setName("亮哥");
stu[4] = new ScoreInformation();
stu[4].setStunumber("20183789");
stu[4].setName("藍日的");
stu[5] = new ScoreInformation();
stu[5].setStunumber("20183767");
stu[5].setName("帥哥");
}
//菜單
static public void manu()
{
System.out.println("***********************************************************");
System.out.println(" 石家莊鐵道大學軟件工程系 ");
System.out.println(" 學生學籍管理系統 2019 版 ");
System.out.println("***********************************************************");
System.out.println(" 1、 學生考試成績錄入 ");
System.out.println(" 2、 學生考試成績修改 ");
System.out.println(" 3、 計算學生成績績點");
System.out.println(" 4、退出學籍管理系統");
System.out.println("***********************************************************");
}
//錄入
static public void luru()
{
System.out.println("***********************************************************");
System.out.println(" 石家莊鐵道大學軟件工程系學生學籍管理系統 2019 版 ");
System.out.println(" 學生考試成績錄入");
System.out.println("***********************************************************");
System.out.println(" 請輸入學生學號:XXXXXXXX");
System.out.println("***********************************************************");
String scan_num = scan.next();
for(i=0;i<6;i++)
{
if(scan_num.equals(stu[i].getStunumber()))
{
tag=false;
break;
}
}
if(tag==true)
{
System.out.println("不存在");
}
//存在并且繼續輸入成績
else
{
System.out.println("***********************************************************");
System.out.println(" 石家莊鐵道大學軟件工程系學生學籍管理系統 2019 版 ");
System.out.println(" 學生考試成績錄入界面");
System.out.println(" 學生學號:"+scan_num);
System.out.println(" 學生姓名:"+stu[i].getName());
System.out.println(" 請輸入高等數學成績:XXX");
System.out.println("***********************************************************");
stu[i].setMathematicsscore(scan.nextDouble());
System.out.println("***********************************************************");
System.out.println(" 石家莊鐵道大學軟件工程系學生學籍管理系統 2019 版 ");
System.out.println(" 學生考試成績錄入界面");
System.out.println(" 學生學號:"+scan_num);
System.out.println(" 學生姓名:"+stu[i].getName());
System.out.println(" 高等數學成績:"+stu[i].getMathematicsscore());
System.out.println(" 請輸入英語成績:XXX");
System.out.println("***********************************************************");
stu[i].setEnglishiscore(scan.nextDouble());
System.out.println("***********************************************************");
System.out.println(" 石家莊鐵道大學軟件工程系學生學籍管理系統 2019 版 ");
System.out.println(" 學生考試成績錄入界面");
System.out.println(" 學生學號:"+scan_num);
System.out.println(" 學生姓名:"+stu[i].getName());
System.out.println(" 高等數學成績:"+stu[i].getMathematicsscore());
System.out.println(" 英語成績:"+stu[i].getEnglishiscore());
System.out.println(" 請輸入計算機網絡成績:XXX");
System.out.println("***********************************************************");
stu[i].setNetworkscore(scan.nextDouble());
System.out.println("***********************************************************");
System.out.println(" 石家莊鐵道大學軟件工程系學生學籍管理系統 2019 版 ");
System.out.println(" 學生考試成績錄入界面");
System.out.println(" 學生學號:"+scan_num);
System.out.println(" 學生姓名:"+stu[i].getName());
System.out.println(" 高等數學成績:"+stu[i].getMathematicsscore());
System.out.println(" 英語成績:"+stu[i].getEnglishiscore());
System.out.println(" 計算機網絡成績:"+stu[i].getNetworkscore());
System.out.println(" 請輸入數據庫成績:XXX");
System.out.println("***********************************************************");
stu[i].setDatabasescore(scan.nextDouble());
System.out.println("***********************************************************");
System.out.println(" 石家莊鐵道大學軟件工程系學生學籍管理系統 2019 版 ");
System.out.println(" 學生考試成績錄入界面");
System.out.println(" 學生學號:"+scan_num);
System.out.println(" 學生姓名:"+stu[i].getName());
System.out.println(" 高等數學成績:"+stu[i].getMathematicsscore());
System.out.println(" 英語成績:"+stu[i].getEnglishiscore());
System.out.println(" 計算機網絡成績:"+stu[i].getNetworkscore());
System.out.println(" 數據庫成績:"+stu[i].getDatabasescore());
System.out.println(" 請輸入軟件工程成績:XXX");
System.out.println("***********************************************************");
stu[i].setSoftwarescore(scan.nextDouble());
System.out.println("***********************************************************");
System.out.println(" 石家莊鐵道大學軟件工程系學生學籍管理系統 2019 版 ");
System.out.println(" 學生考試成績錄入界面");
System.out.println(" 學生學號:"+scan_num);
System.out.println(" 學生姓名:"+stu[i].getName());
System.out.println(" 高等數學成績:"+stu[i].getMathematicsscore());
System.out.println(" 英語成績:"+stu[i].getEnglishiscore());
System.out.println(" 計算機網絡成績:"+stu[i].getNetworkscore());
System.out.println(" 數據庫成績:"+stu[i].getDatabasescore());
System.out.println(" 軟件工程成績:"+stu[i].getSoftwarescore());
System.out.println("***********************************************************");
System.out.println(" 該學生成績已錄入完畢,是否提交(Y/N)");
String x = scan.next();
//輸入完確認
if(x=="Y")
{
manu();
}
else if(x=="N")
{
stu[i].setDatabasescore(0.0);
stu[i].setEnglishiscore(0.0);
stu[i].setMathematicsscore(0.0);
stu[i].setDatabasescore(0.0);
stu[i].setNetworkscore(0.0);
luru();
}
}
}
//修改
static void xiugai()
{
System.out.println("***********************************************************");
System.out.println(" 石家莊鐵道大學軟件工程系學生學籍管理系統 2019 版 ");
System.out.println(" 學生考試成績修改界面");
System.out.println("***********************************************************");
System.out.println(" 請輸入學生學號:XXXXXXXX");
System.out.println("***********************************************************");
String scan_num2 = scan.next();
for(i=0;i<6;i++)
{
if(scan_num2.equals(stu[i].getStunumber()))
{
tag=false;
break;
}
}
if(tag==true)
{
System.out.println("學號不存在");
xiugai();
}
else
{
System.out.println("***********************************************************");
System.out.println(" 石家莊鐵道大學軟件工程系學生學籍管理系統 2019 版 ");
System.out.println(" 學生考試成績錄入");
System.out.println("***********************************************************");
System.out.println(" 學生學號:"+scan_num2);
System.out.println(" 學生姓名:"+stu[i].getName());
System.out.println(" 1.高等數學成績:"+stu[i].getMathematicsscore());
System.out.println(" 2.英語成績:"+stu[i].getEnglishiscore());
System.out.println(" 3.計算機網絡成績:"+stu[i].getNetworkscore());
System.out.println(" 4.數據庫成績:"+stu[i].getDatabasescore());
System.out.println(" 5.軟件工程成績:"+stu[i].getSoftwarescore());
System.out.println("***********************************************************");
int xuanze=scan.nextInt();
double xiugai=0.0;
switch(xuanze) {
case 1:
System.out.println("***********************************************************");
System.out.println(" 石家莊鐵道大學軟件工程系學生學籍管理系統 2019 版 ");
System.out.println(" 學生考試成績錄入界面");
System.out.println("***********************************************************");
System.out.println(" 學生學號:"+scan_num2);
System.out.println(" 學生姓名:"+stu[i].getName());
System.out.println(" 請輸入修改后高等數學成績:XXX");
xiugai=stu[i].getMathematicsscore();
stu[i].setMathematicsscore(scan.nextDouble());break;
case 2:
System.out.println("***********************************************************");
System.out.println(" 石家莊鐵道大學軟件工程系學生學籍管理系統 2019 版 ");
System.out.println(" 學生考試成績錄入界面");
System.out.println("***********************************************************");
System.out.println(" 學生學號:"+scan_num2);
System.out.println(" 學生姓名:"+stu[i].getName());
System.out.println(" 請輸入修改后英語成績:XXX");
xiugai=stu[i].getEnglishiscore();
stu[i].setEnglishiscore(scan.nextDouble());break;
case 3:
System.out.println("***********************************************************");
System.out.println(" 石家莊鐵道大學軟件工程系學生學籍管理系統 2019 版 ");
System.out.println(" 學生考試成績錄入界面");
System.out.println("***********************************************************");
System.out.println(" 學生學號:"+scan_num2);
System.out.println(" 學生姓名:"+stu[i].getName());
System.out.println(" 請輸入修改后計算機網絡成績:XXX");
xiugai=stu[i].getNetworkscore();
stu[i].setNetworkscore(scan.nextDouble());break;
case 4:
System.out.println("***********************************************************");
System.out.println(" 石家莊鐵道大學軟件工程系學生學籍管理系統 2019 版 ");
System.out.println(" 學生考試成績錄入界面");
System.out.println("***********************************************************");
System.out.println(" 學生學號:"+scan_num2);
System.out.println(" 學生姓名:"+stu[i].getName());
System.out.println(" 請輸入修改后數據庫成績:XXX");
xiugai=stu[i].getDatabasescore();
stu[i].setDatabasescore(scan.nextDouble());break;
case 5:
System.out.println("***********************************************************");
System.out.println(" 石家莊鐵道大學軟件工程系學生學籍管理系統 2019 版 ");
System.out.println(" 學生考試成績錄入界面");
System.out.println("***********************************************************");
System.out.println(" 學生學號:"+scan_num2);
System.out.println(" 學生姓名:"+stu[i].getName());
System.out.println(" 請輸入修改后軟件工程成績:XXX");
xiugai=stu[i].getSoftwarescore();
stu[i].setSoftwarescore(scan.nextDouble());break;
}
System.out.println("***********************************************************");
System.out.println(" 石家莊鐵道大學軟件工程系學生學籍管理系統 2019 版 ");
System.out.println(" 學生考試成績錄入");
System.out.println("***********************************************************");
System.out.println(" 學生學號:"+scan_num2);
System.out.println(" 學生姓名:"+stu[i].getName());
System.out.println(" 1.高等數學成績:"+stu[i].getMathematicsscore());
System.out.println(" 2.英語成績:"+stu[i].getEnglishiscore());
System.out.println(" 3.計算機網絡成績:"+stu[i].getNetworkscore());
System.out.println(" 4.數據庫成績:"+stu[i].getDatabasescore());
System.out.println(" 5.軟件工程成績:"+stu[i].getSoftwarescore());
System.out.println(" 該學生成績已修改完畢,是否提交(Y/N)");
System.out.println("***********************************************************");
String y= scan.next();
//輸入完確認
if(y=="Y")
{
manu();
}
else if(y=="N")
{
switch(xuanze) {
case 1:stu[i].setMathematicsscore(xiugai);break;
case 2:stu[i].setEnglishiscore(xiugai);break;
case 3:stu[i].setNetworkscore(xiugai);break;
case 4:stu[i].setDatabasescore(xiugai);break;
case 5:stu[i].setSoftwarescore(xiugai);break;
}
xiugai();
}
}
}
//績點
static void jidian()
{
System.out.println("***********************************************************");
System.out.println(" 石家莊鐵道大學軟件工程系學生學籍管理系統 2019 版 ");
System.out.println(" 學生考試成績績點計算界面");
System.out.println("***********************************************************");
System.out.println(" 請輸入學生學號:XXXXXXXX");
System.out.println("***********************************************************");
String scan_num3 = scan.next();
for(i=0;i<6;i++)
{
if(scan_num3.equals(stu[i].getStunumber()))
{
tag=false;
break;
}
}
if(tag==true)
{
System.out.println("學號不存在");
jidian();
}
else
{
System.out.println("***********************************************************");
System.out.println(" 石家莊鐵道大學軟件工程系學生學籍管理系統 2019 版 ");
System.out.println(" 學生考試成績績點計算界面");
System.out.println("***********************************************************");
System.out.println(" 學生學號:"+scan_num3);
System.out.println(" 學生姓名:"+stu[i].getName());
System.out.println(" 1.高等數學績點:"+js(stu[i].getMathematicsscore()));
System.out.println(" 2.英語績點:"+js(stu[i].getEnglishiscore()));
System.out.println(" 3.計算機網絡績點:"+js(stu[i].getNetworkscore()));
System.out.println(" 4.數據庫績點:"+js(stu[i].getDatabasescore()));
System.out.println(" 5.軟件工程績點:"+js(stu[i].getSoftwarescore()));
double pj=0.0;
pj=(js(stu[i].getMathematicsscore())*4.0+js(stu[i].getEnglishiscore())*3.0+js(stu[i].getNetworkscore())*4.0
+js(stu[i].getDatabasescore())*3.0+js(stu[i].getSoftwarescore())*2.0)/(16.0);
if(pj>=2.0)
{
System.out.println(" 你的平均學分績點為:"+(double)Math.round(pj*100)/100);
System.out.println(" 您已合格");
}
else
{
System.out.println(" 你的平均學分績點為:"+(double)Math.round(pj*100)/100);
System.out.println(" 您未合格");
}
System.out.println("***********************************************************");
}
}
static public double js(Double cj)
{
double xf=0.0;
if(cj>=90)
xf=4.0;
else if(cj>=85)
xf=3.7;
else if(cj>=82)
xf=3.3;
else if(cj>=78)
xf=3.0;
else if(cj>=75)
xf=2.7;
else if(cj>=72)
xf=2.3;
else if(cj>=68)
xf=2.0;
else if(cj>=66)
xf=1.7;
else if(cj>=64)
xf=1.5;
else if(cj>=60)
xf=1.0;
else
xf=0;
return xf;
}
}
感想:很多地方都是來自于其他同學,不管從思路,從一些語法,結構,編寫的過程中各種碰壁,好多地方有思路不會寫,要么就是沒思路,看著別人的代碼能看懂但是也很吃力,自己寫就更不用說了,總體來說還是欠練,之后我會繼續檢查這個題,到目前為止只是停留在能運行出來,功能是否全部實現還不確定,錄入的代碼好像有點錯誤,等我繼續檢查一遍整理一下思路再寫一遍,希望自己能越來越熟練,加油。
總結
- 上一篇: Boost中的Timer的使用——计算时
- 下一篇: m2接口长什么样(M2到底是什么)