当前位置:首页 » 编程语言 » java成绩管理系统

java成绩管理系统

发布时间: 2022-07-07 07:17:09

❶ 速求java学生成绩管理系统 用数组 不要用数据库

public class Test04
{
public static List<Students> list = new ArrayList<Students>();
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
int t;
while(true){
System.out.println("学生成绩管理系统");
System.out.println("1.输入记录");
System.out.println("2.输出所有记录");
System.out.println("3.按平均成绩排序并输出");
System.out.println("4.查找记录");
System.out.println("5.统计个分数段人数");
System.out.println("6.删除记录");
System.out.println("7.退出");
System.out.println("请输入你的操作(1-7):");
String s = scan.nextLine();
if (null==s||"".equals(s))
{
continue;
}else {
t = Integer.parseInt(s);
}
if (0==t)
{
break;
}
}
}
}
class Students{
int id;
String name;
}
后面可以自己做判断,写方法实现

❷ java编写学生成绩管理系统

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Admin {

public static void main(String[] args) throws IOException, ClassNotFoundException {
Scanner in = new Scanner(System.in);
int studentNum = 5;

List<Student> result = new ArrayList<Student>();
for (int i = 0; i < studentNum; i++) {
Student bean = new Student();
System.out.print("输入第" + (i + 1) + "个学生学号:");
bean.setNo(in.next());
System.out.print("输入第" + (i + 1) + "个学生姓名:");
bean.setName(in.next());
System.out.print("输入第" + (i + 1) + "个学生数学成绩:");
bean.setShuxue(in.nextDouble());
System.out.print("输入第" + (i + 1) + "个学生语文成绩:");
bean.setYuwen(in.nextDouble());
result.add(bean);
}

while (true) {
System.out.println("1.保存到文件;2.总成绩;3.平均成绩;4.不及格比例;5.及格比例;6,优良比例;0.退出.");
int i = in.nextInt();

if (i == 0) {
System.exit(0);
}

if (i == 1) {
save(result);
}

if (i == 2) {
for (int j = 0; j < result.size(); j++) {
Student s = result.get(j);
System.out.println("学生" + s.getName() + "的总成绩是:" + s.all());
}
}

if (i == 3) {
int jigeSum = 0;
for (int j = 0; j < result.size(); j++) {
Student s = result.get(j);
if (!s.isJige()) {
jigeSum++;
}
}
System.out.println("不及格比例:" + jigeSum + "/" + result.size());
}
if (i == 4) {
// 篇幅受限,自行开发
}
if (i == 5) {
// 篇幅受限,自行开发
}
}
}

private static void save(List result) throws IOException {
FileOutputStream fs = new FileOutputStream("d:/a.txt");
ObjectOutputStream os = new ObjectOutputStream(fs);
os.writeObject(result);
os.flush();
os.close();
fs.close();
}
}

class Student implements Serializable {

private String no;

private String name;

private double shuxue;

private double yuwen;

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getNo() {
return no;
}

public void setNo(String no) {
this.no = no;
}

public double getShuxue() {
return shuxue;
}

public void setShuxue(double shuxue) {
this.shuxue = shuxue;
}

public double getYuwen() {
return yuwen;
}

public void setYuwen(double yuwen) {
this.yuwen = yuwen;
}

public double all() {
return shuxue + yuwen;
}

public double avg() {
return all() / 2;
}

public boolean isJige() {
return avg() > 60;
}
}

❸ java设计一个学生成绩管理系统

public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);

String exit="";
Map<String, List<Float>> map1=new HashMap();
while(!exit.equals("exit")) {
System.out.println("请出入学生姓名");
List<Float> list = new ArrayList<Float>();
map1.put(sc.next(), list);
for(int i=0;i<3;i++) {
System.out.println("请出入学生成绩");
list.add(sc.nextFloat());
}
System.out.println("输入 exit 退出成绩录入,其他则继续录入");
exit=sc.next();
}
for(String key :map1.keySet()) {
List<Float> list =map1.get(key);
float avage =0l;
for(Float box :list) {
avage += box;
}
System.out.println(key+"的平均成绩:"+ avage/list.size());
}

}
//只做了第一题,追加分数,可得第二题答案

❹ JAVA程序设计 学生成绩管理系统(数据库版)

那个不好意思,我来当坏人吧,没人会鸟你的,这世界好人没人想的那么多,最简单的自己在网络搜一个,但是一般数据库或者jdk版本会不兼容,还有你的悬赏太少了,根本没有人会来回答的,我建议你还自己堆起来吧,这个不难,只是堆代码而已,现在eclipse都可以拖放swing部件了

❺ 用java做一个学生成绩管理系统需要哪些技术

用java做一个学生成绩管理系统,可以用到如下技术:

后台:SSH框架,不用框架的话,单纯地用JSP + Servlet也可以。

前台:html + css + js + jquery

数据库:掌握sql语言的编写,数据库的连接。复杂的项目还需要用到存储过程。

❻ 求用Java编写的学生成绩管理系统的完整代码

packagejdbcproj;
importjava.sql.*;
importjava.awt.BorderLayout;
importjava.awt.EventQueue;

importjavax.swing.JFrame;
importjavax.swing.JPanel;
importjavax.swing.border.EmptyBorder;
importjavax.swing.JLabel;
importjavax.swing.JOptionPane;
importjavax.swing.JTextField;
importjavax.swing.JButton;
importjava.awt.event.ActionListener;
importjava.sql.Connection;
importjava.sql.PreparedStatement;
importjava.sql.SQLException;
importjava.awt.event.ActionEvent;

{

privateJPanelcontentPane;
privateJTextFieldtxtname;
privateJTextFieldtxtpassword;


/**
*Launchtheapplication.
*/
publicstaticvoidmain(String[]args){
EventQueue.invokeLater(newRunnable(){
publicvoidrun(){
try{
MainFrameframe=newMainFrame();
frame.setVisible(true);
}catch(Exceptione){
e.printStackTrace();
}
}
});
}

/**
*Createtheframe.
*/
publicMainFrame(){
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100,100,661,399);
contentPane=newJPanel();
contentPane.setBorder(newEmptyBorder(5,5,5,5));
setContentPane(contentPane);
contentPane.setLayout(null);

JLabellblNewLabel=newJLabel("u7528u6237u540D");
lblNewLabel.setBounds(114,51,72,18);
contentPane.add(lblNewLabel);

JLabellblNewLabel_1=newJLabel("u5BC6u7801");
lblNewLabel_1.setBounds(114,106,72,18);
contentPane.add(lblNewLabel_1);

txtname=newJTextField();
txtname.setBounds(261,48,86,24);
contentPane.add(txtname);
txtname.setColumns(10);

txtpassword=newJTextField();
txtpassword.setBounds(261,103,86,24);
contentPane.add(txtpassword);
txtpassword.setColumns(10);

JButtonbtnadd=newJButton("u589Eu52A0");
btnadd.addActionListener(newActionListener(){
publicvoidactionPerformed(ActionEvente){
if(txtname.getText().equals("")||txtpassword.getText().equals(""))
{
JOptionPane.showMessageDialog(getContentPane(),"用户名和密码不能为空","提示信息框",JOptionPane.WARNING_MESSAGE);
}
else{
Usersu=newUsers();
u.setPwd(txtpassword.getText());
u.setUsername(txtname.getText());
UserDAOusdo=newUserDAO();
usdo.addUser(u);
}
}
});
btnadd.setBounds(45,205,113,27);
contentPane.add(btnadd);

JButtonbtndelete=newJButton("u5220u9664");
btndelete.addActionListener(newActionListener(){
publicvoidactionPerformed(ActionEventarg0){
if(txtname.getText().equals(""))
{
JOptionPane.showMessageDialog(getContentPane(),"用户名不能为空","提示信息框",JOptionPane.WARNING_MESSAGE);
}
else{
UserDAOusdo=newUserDAO();
usdo.delUser(txtname.getText());;
}
}
});
btndelete.setBounds(172,205,113,27);
contentPane.add(btndelete);

JButtonbtnupdate=newJButton("u4FEEu6539");
btnupdate.addActionListener(newActionListener(){
publicvoidactionPerformed(ActionEvente){
if(txtname.getText().equals("")||txtpassword.getText().equals(""))
{
JOptionPane.showMessageDialog(getContentPane(),"用户名和密码不能为空","提示信息框",JOptionPane.WARNING_MESSAGE);
}
else{
Usersu=newUsers();
u.setPwd(txtpassword.getText());
u.setUsername(txtname.getText());
UserDAOusdo=newUserDAO();
usdo.updateUser(u);;
}
}
});
btnupdate.setBounds(300,205,113,27);
contentPane.add(btnupdate);

JButtonbtnfind=newJButton("u67E5u8BE2");
btnfind.addActionListener(newActionListener(){
publicvoidactionPerformed(ActionEvente){
if(txtname.getText().equals(""))
{
JOptionPane.showMessageDialog(getContentPane(),"用户名不能为空","提示信息框",JOptionPane.WARNING_MESSAGE);
}
else{
Usersu=newUsers();
UserDAOusdo=newUserDAO();
u=usdo.findUser(txtname.getText(),txtpassword.getText());
if(u!=null){
JOptionPane.showMessageDialog(getContentPane(),"该用户存在!","提示信息框",JOptionPane.WARNING_MESSAGE);
}
else{
JOptionPane.showMessageDialog(getContentPane(),"该用户不存在!","提示信息框",JOptionPane.WARNING_MESSAGE);
}
}
}
});
btnfind.setBounds(427,205,113,27);
contentPane.add(btnfind);
//记得要写这个
setVisible(true);
}

}

❼ JAVA:编写一个学生成绩管理系统。学生的属性包括学号、姓名、年龄等。

classStudent{
Stringname;
Stringid;
intage;
Couse[]course;
}
classCourse{
Stringcoursename;
floatpscourse;
floatqzcourse;
floatsxcourse;
floatqmcourse;
floatzpcourse;
}
这个要写好长时间的,定义几个类;然后实现具体的功能。用数组或者集合来存储学生信息还有成绩信息,最后定义一个测试类。你可以找我私聊,1368270359qq

❽ 基于java设计一个学生成绩管理系统,要求有界面,且有增加,查询,修改,删除,退出功能,代码如何写

import java.awt.Color;
import java.awt.Font;
import java.awt.Frame;
import java.awt.Label;
import java.awt.TextField;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.sql.SQLException;

import javax.swing.JButton;

public class Stmessege {
Font font = new Font("楷体", Font.BOLD, 18);
private Frame m = new Frame("登陆成功界面");
protected Window f;

public Stmessege() {

m.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent evt) {
m.setVisible(false);
m.dispose();
System.exit(0);
}
});
m.setSize(460, 360);
m.setBackground(Color.green);
m.setLayout(null);
m.setLocationRelativeTo(null);

Label l0 = new Label("管理员信息");
Font font1 = new Font("楷体", Font.BOLD, 32);
l0.setForeground(Color.blue);
l0.setSize(180, 50);
l0.setLocation(150, 30);
l0.setFont(font1);

final Label l1 = new Label("姓名:");
l1.setSize(60, 20);
l1.setLocation(10, 100);
l1.setFont(font);

TextField tf1 = new TextField("黄朋");
tf1.setForeground(Color.blue);
tf1.setBackground(Color.white);
tf1.setSize(50, 20);
tf1.setLocation(70, 100);

final Label l2 = new Label("学号:");
l2.setSize(60, 20);
l2.setLocation(140, 100);
l2.setFont(font);

TextField tf2 = new TextField("111265");
tf2.setForeground(Color.blue);
tf2.setBackground(Color.white);
tf2.setSize(60, 20);
tf2.setLocation(190, 100);

final Label l3 = new Label("性别:");
l3.setSize(60, 20);
l3.setLocation(280, 100);
l3.setFont(font);

TextField tf3 = new TextField("男");
tf3.setForeground(Color.blue);
tf3.setBackground(Color.white);
tf3.setSize(40, 20);
tf3.setLocation(360, 100);

final Label l4 = new Label("班级:");
l4.setSize(60, 20);
l4.setLocation(10, 170);
l4.setFont(font);

TextField tf4 = new TextField("611231");
tf4.setForeground(Color.blue);
tf4.setBackground(Color.white);
tf4.setSize(60, 20);
tf4.setLocation(67, 170);

final Label l5 = new Label("系别:");
l5.setSize(60, 20);
l5.setLocation(140, 170);
l5.setFont(font);

TextField tf5 = new TextField("计算机工程系");
tf5.setForeground(Color.blue);
tf5.setBackground(Color.white);
tf5.setSize(80, 20);
tf5.setLocation(200, 170);

final Label l6 = new Label("成绩:");
l6.setSize(60, 20);
l6.setLocation(280, 170);
l6.setFont(font);

TextField tf6 = new TextField("95");
tf6.setForeground(Color.blue);
tf6.setBackground(Color.white);
tf6.setSize(40, 20);
tf6.setLocation(360, 170);

final Label l7 = new Label("专业:");
l7.setSize(60, 20);
l7.setLocation(10, 230);
l7.setFont(font);

TextField tf7 = new TextField("软件技术");
tf7.setForeground(Color.blue);
tf7.setBackground(Color.white);
tf7.setSize(60, 20);
tf7.setLocation(70, 230);

JButton btn1 = new JButton("添加");
btn1.setForeground(Color.blue);
btn1.setSize(80, 38);
btn1.setLocation(35, 300);
btn1.setFont(font);
btn1.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
new 插入();
m.setVisible(true);
}
});
JButton btn2 = new JButton("查询学生学籍信息");
btn2.setForeground(Color.blue);
btn2.setSize(200, 38);
btn2.setLocation(135, 300);
btn2.setFont(font);

btn2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Stmessege1 f;
try {
f = new Stmessege1();
f.Stmessege11();
m.setVisible(true);

} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (ClassNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
});

JButton btn3 = new JButton("删除");
btn3.setForeground(Color.blue);
btn3.setSize(80, 38);
btn3.setLocation(350, 300);
btn3.setFont(font);
btn3.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub

new 删除();
//f.setVisible(false);
m.setVisible(true);
}
});

JButton btn4 = new JButton("更新");
btn4.setForeground(Color.blue);
btn4.setSize(80, 38);
btn4.setLocation(200, 230);
btn4.setFont(font);
btn4.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
new 更新();
m.setVisible(true);

}
});

m.add(l0);
m.add(l1);

m.add(tf1);
m.add(l2);

m.add(tf2);
m.add(l3);

m.add(tf3);
m.add(l4);

m.add(tf4);
m.add(l5);

m.add(tf5);
m.add(l6);
m.add(tf6);

m.add(l7);
m.add(tf7);

m.add(btn1);
m.add(btn2);
m.add(btn3);
m.add(btn4);

m.setVisible(true);

}

public static void main(String[] args) {
new Stmessege();
}
}

可以仿照我的做一下,希望采纳,我才一级哦

❾ 如何用Java语言编写学生成绩管理系统

写过一个类似的给了你吧

packagestudent;

importjava.util.Scanner;

publicclassteststudent{

publicstaticvoidmain(Stringargs[]){
System.out.println("************************学生成绩管理系统*********************");
System.out.println("请输入要管理的学生人数:");
Scannersc=newScanner(System.in);
intn=sc.nextInt();
studentMassagestum=newstudentMassage(n);

intflag=1;
while(flag==1){
System.out.println("1.输入学生信息");
System.out.println("2.通过姓名查找学生信息");
System.out.println("3.显示全部学生信息");
System.out.println("4.退出系统");

intop=sc.nextInt();
switch(op){
case1:stum.addStudent(n);
newScanner(System.in).nextLine();
break;
case2:
System.out.println("输入学生姓名:");
Stringname=sc.next();
stum.FindStudent(name);
newScanner(System.in).nextLine();
break;
case3:
stum.showallStudent();
newScanner(System.in).nextLine();
break;
case4:
flag=0;
System.out.println("已退出系统!");
break;
default:
System.out.println("输入有误!");
newScanner(System.in).nextLine();
}

}
}

}
classDate{
intyear;
intmonth;
intday;
/*publicDate(intyear,intmonth,intday){
this.year=year;
this.month=month;
this.day=day;

}
publicDate(){}*/
publicStringshowDate(){
returnyear+"/"+month+"/"+day;
}
}
classstudent{
intid;
Stringname;
Datedate;
floatscore;
publicstudent(){
id=0;
name=null;
date=null;
score=0f;
}
publicvoidshowStudent(){
System.out.println(id+""+name+""+""+date.showDate()+""+score);
}
}
classstudentMassage{
privatestudent[]stu;
privateintflag;
publicstudentMassage(intn){
flag=0;
if(stu==null){
stu=newstudent[n];
for(inti=0;i<n;++i){
stu[i]=newstudent();
}
}
}
publicvoidaddStudent(intn){
flag=1;
Scannersc=newScanner(System.in);
System.out.println("请输入"+n+"个学生信息");
for(inti=0;i<stu.length;++i){
stu[i].date=newDate();
System.out.println("请输入第"+(i+1)+"个学生学号:");
stu[i].id=sc.nextInt();
System.out.println("请输入第"+(i+1)+"个学生姓名:");
stu[i].name=sc.next();
System.out.println("请输入第"+(i+1)+"个学生出生年份:");
stu[i].date.year=sc.nextInt();
System.out.println("请输入第"+(i+1)+"个学生出生月份:");
stu[i].date.month=sc.nextInt();
System.out.println("请输入第"+(i+1)+"个学生出生日期:");
stu[i].date.day=sc.nextInt();
//stu[i].date=newDate(year,month,day);
System.out.println("请输入第"+(i+1)+"个学生分数:");
stu[i].score=sc.nextFloat();
}
}
publicvoidFindStudent(Stringsname){
studentfind=null;
if(flag!=0){
for(inti=0;i<stu.length;++i){
if(sname.equals(stu[i].name))
find=stu[i];
}
if(find==null)
System.out.println("查无此人!");
else
find.showStudent();
}else
System.out.println("没有输入学生信息!");

}
publicvoidshowallStudent(){
System.out.println("所有学生的信息如下:");
System.out.println("学号姓名生日分数");
for(inti=0;i<stu.length;++i){
stu[i].showStudent();
}
}
}

❿ 用java编写一个学生成绩管理系统. //1.学生类 学号 姓名 年龄 语数外三科成绩(三科成绩)

  1. 用数组可以,也可以用集合来存储各个同学的成绩。

  2. 添加删除等信息简单。

这里有个迷你图书管理系统,类似,我刚写的。你看看之后应该会有思路了。如果用集合utils做的话,也简单,知识用到了集合框架和泛型等机制。

package cn.kgc.sg.MiTuSys;


import java.util.Scanner;


public class MiNiBookSys {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

// 定义书的信息

String[] bookNames = new String[4];

int[] borrowDate = new int[5];

int[] borrowCount = new int[4];

int[] states = new int[4];

// 定义书单信息

String[] bookMeg = new String[5];

bookMeg[0] = "Java开发";

bookMeg[1] = "C#开发";

bookMeg[2] = "C语言开发";

states[2] = 0; // 0:可借阅 1:已借出


// 初始化两个图书借阅记录信息

bookNames[0] = "安徒生童话";

borrowDate[0] = 15;

borrowCount[0] = 4;

states[0] = 0; // 0:可借阅 1:已借出

bookNames[1] = "格林童话";

states[1] = 1; // 0:可借阅 1:已借出

borrowDate[1] = 26;

borrowCount[1] = 9;


// 搭建项目框架

int num = -1;// 定义用户初始输入的数字

do {

System.out.println("*********************欢迎使用图书管理系统**********************");

System.out.println(" 1.新增图书");

System.out.println(" 2.查看图书");

System.out.println(" 3.删除图书");

System.out.println(" 4.图书借阅");

System.out.println(" 5.归还图书");

System.out.println(" 6.退出系统");


System.out.print("请输入您的选择:");

int choose = sc.nextInt();

// 判断输入的选择是否正确

while (choose < 0 || choose > 6) {

System.out.print("输入有误,请重新输入:");

choose = sc.nextInt();

}

// 定义一个flag变量,来定义是否退出系统

boolean flag = true;// true:不退出系统 false:退出系统

String addName = null;

switch (choose) {

case 1:

System.out.println(" *********1.新增图书*********");

boolean isAdd = true;

System.out.println("序号 图书书名");

for (int i = 0; i < bookMeg.length; i++) {

// 判断为空的不输出

if (bookMeg[i] != null) {

System.out.println((i + 1) + " " + bookMeg[i]);

}

}

System.out.print("请输入新增图书名称:");

addName = sc.next();

for (int i = 0; i <bookMeg.length; i++) {

// 判断为空的不输出

if (bookMeg[i] == null) {

bookMeg[i] = addName;

break;

}

}

/*bookMeg[bookMeg.length-1] = addName; //添加图书信息

*/ System.out.println(" 序号 图书书名");

for (int i = 0; i < bookMeg.length; i++) {

// 判断为空的不输出

if (bookMeg[i] != null) {

System.out.println((i + 1) + " " + bookMeg[i]);

}

}

if (!isAdd) {

System.out.println("对不起,图书已满,不能添加!!!");

}

break;


case 2:

System.out.println(" *********2.查看图书*********");

System.out.println("序号" + " 图书书名" + " 借阅次数 借阅状态 借阅日期 ");

// 遍历数组

for (int i = 0; i < bookNames.length; i++) {

// 判断信息为空的不输出

if (bookNames[i] != null) {

String borrowCounts = borrowCount[i] + "次";

String borrowDates = borrowDate[i] + "日";

String state = (states[i] == 0) ? "可借阅" : "已借出";

System.out.println((i + 1) + " " + bookNames[i] + " " + borrowCounts + " " + state

+ " " + borrowDates);

}

}

break;


case 3:

System.out.println(" *********3.删除图书*********");

System.out.println("序号 图书书名");

for (int i = 0; i < bookMeg.length; i++) {

// 判断为空的不输出

if (bookMeg[i] != null) {

System.out.println((i + 1) + " " + bookMeg[i]);

}

}

System.out.print("请输入删除的图书序号:");

int delNo = sc.nextInt();

// 判断输入的序号是否有误

while (delNo < 1 || delNo > bookMeg.length) {

System.out.print("输入有误,重新输入:");

delNo = sc.nextInt();

}

// 删除图书

for (int i = 0; i <=bookMeg.length-1;i++) {

if (bookMeg[i] != null && i == delNo - 1) {

bookMeg[i] = bookMeg[i+1];

bookMeg[i+1] = null; //

// 最后置空

bookMeg[bookMeg.length - 1] = null;

}

}

for (int i = 0; i < bookMeg.length; i++) {

// 判断为空的不输出

if (bookMeg[i] != null) {

System.out.println((i + 1) + " " + bookMeg[i]);

}

}

break;


case 4:

System.out.println(" *********4.图书借阅*********");

System.out.println(" 序号 图书书名 借阅状态 借阅次数 借阅日期");

for (int i = 0; i < bookMeg.length; i++) {

// 判断为空的不输出

if (bookMeg[i] != null) {

String state = (states[i] == 0) ? "可借阅" : "已借出";

String borrowCi = borrowCount[i] + "次";

System.out.println((i + 1) + " " + bookMeg[i] + " " + state + " " + borrowCi + " "

+ borrowDate[i]);

}

}

System.out.print("请输入您要借阅的图书序号:");

int borrowNo = sc.nextInt();

boolean isFind = true;// false:找不到


for (int i = 0; i < bookMeg.length; i++) {

// 查到了,但是状态是0可借阅,可以借阅

if (i == borrowNo - 1 && states[i] == 0) {

isFind = true;

// 改变状态为已借出

states[i] = 1;

// 借阅次数加一

borrowCount[i]++;

// 输入借阅日期

System.out.print("请输入借阅日期:");

int borrow = sc.nextInt();

// 对输入的日期判断

while (borrow < 1 || borrow > 31) {

System.out.print("您输入日期有误,请重新输入:");

borrow = sc.nextInt();

}

// 更新借阅日期

borrowDate[i] = borrow;

} else if (i == borrowNo - 1 && states[i] == 1) {

// 查到了,但是状态是1已借出,不可以借阅

isFind = true;

System.out.println("状态是已借出,不可以借阅!!!");

}

}

if (!isFind) {

System.out.println("找不到图书!");

break;

}

break;


case 5:

System.out.println(" *********5.归还图书*********");

System.out.println(" 序号 图书书名 借阅状态 借阅次数 借阅日期");

for (int i = 0; i < bookMeg.length; i++) {

// 判断为空的不输出

if (bookMeg[i] != null) {

String state = (states[i] == 0) ? "可借阅" : "已借出";

String borrowCi = borrowCount[i] + "次";

System.out.println((i + 1) + " " + bookMeg[i] + " " + state + " " + borrowCi + " "

+ borrowDate[i]);

}

}

System.out.print("请输入您要归还的图书序号:");

int huanNo = sc.nextInt();

// 判断归还的序号是否合法

while (huanNo < 1 || huanNo > bookMeg.length - 1) {

System.out.print("输入的归还图书序号有误,请重新输入:");

huanNo = sc.nextInt();

}

boolean isHuan = true;// false:找不到

for (int i = 0; i < bookMeg.length; i++) {

// 查到了,但是状态是1已借出,可以还

if (i == huanNo - 1 && states[i] == 1) {

isHuan = true;

// 改变状态为已借出

states[i] = 0;

// 输入归还日期

System.out.print("请输入归还日期:");

int huan = sc.nextInt();

// 对归还的日期判断,必须大于借阅日期

while (huan < 1 || huan > 31) {

System.out.print("您输入日期有误,请重新输入(1-31):");

huan = sc.nextInt();

}

while (huan < borrowDate[i]) {

System.out.print("归还日期必须大于借阅日期" + borrowDate[i] + "号,请重新输入:");

huan = sc.nextInt();

}

borrowCount[i]++;

System.out.println("归还图书成功!!!");


} else if (i == huanNo - 1 && states[i] == 0) {

// 查到了,但是状态是0可借阅,不能还

isFind = true;

System.out.println("状态是可借阅,不可以归还!!!");

}

}

if (!isHuan) {

System.out.println("抱歉,找不到图书,不能归还图书!");

break;

}

break;


case 6:

System.out.println(" *********6.退出系统*********");

flag = false;

break;

default:

flag = false;

break;

}

if (flag) {

System.out.print("输入0返回:");

num = sc.nextInt();

} else {

break;

}

} while (num == 0);

System.out.println("**********谢谢使用**********");

}

}

希望能帮到你!!!

热点内容
滑板鞋脚本视频 发布:2025-02-02 09:48:54 浏览:433
群晖怎么玩安卓模拟器 发布:2025-02-02 09:45:23 浏览:557
三星安卓12彩蛋怎么玩 发布:2025-02-02 09:44:39 浏览:743
电脑显示连接服务器错误 发布:2025-02-02 09:24:10 浏览:537
瑞芯微开发板编译 发布:2025-02-02 09:22:54 浏览:147
linux虚拟机用gcc编译时显示错误 发布:2025-02-02 09:14:01 浏览:240
java驼峰 发布:2025-02-02 09:13:26 浏览:652
魔兽脚本怎么用 发布:2025-02-02 09:10:28 浏览:538
linuxadobe 发布:2025-02-02 09:09:43 浏览:212
sql2000数据库连接 发布:2025-02-02 09:09:43 浏览:726