教学管理系统java代码,java课程管理系统源码
简单的JAVA学生管理系统代码···
lListStudent students = new ArrayListStudent();
创新互联专注于企业营销型网站建设、网站重做改版、武清网站定制设计、自适应品牌网站建设、H5技术、商城网站制作、集团公司官网建设、外贸网站建设、高端网站制作、响应式网页设计等建站业务,价格优惠性价比高,为武清等各大城市提供网站开发制作服务。
BufferedReader br = new BufferedReader(new FileReader("D:\student.txt"));
String tmpStr = br.readLine();
while(tmpStr != null){
int firstIndex = tmpStr.indexOf(" ");
int secondIndex = tmpStr.indexOf(" ",firstIndex + 1);
int thirdIndex = tmpStr.indexOf(" ", secondIndex + 1);
int forthIndex = tmpStr.indexOf(" ", thirdIndex + 1);
Integer stuId = Integer.parseInt(tmpStr.substring(0,firstIndex));
String stuName = tmpStr.substring(firstIndex + 1,secondIndex);
Integer stuYW = Integer.parseInt(tmpStr.substring(secondIndex + 1,thirdIndex));
Integer stuSX = Integer.parseInt(tmpStr.substring(thirdIndex + 1,forthIndex));
Integer stuYY = Integer.parseInt(tmpStr.substring(forthIndex + 1));
Student student = new Student();
student.setStuId(stuId);
student.setStuName(stuName);
student.setStuYW(stuYW);
student.setStuSX(stuSX);
student.setStuYY(stuYY);
students.add(student);
tmpStr.readLine();
}
//创建一个学生实体类 封装stuId stuName stuYW stuSx stuYY 这5个属性。。。
//已经帮你把数据拆分出来 并以Student 对象的形式放入集合中了 接下来 给分吧 哇咔咔
怎么用java实现一个简单的学生管理系统
用java写的话,可以用List来实现学生管理系统:
首先,管理系统是针对学生对象的,所以我们先把学生对象就写出来:
package bean;
public class Student {
String name;
String studentId;
String sex;
int grade;
public Student(String name,String studentId,String sex,int grade){
this.name= name;
this.studentId= studentId;
this.sex = sex;
this.grade = grade;
}
public int getGrade(){
return grade;
}
public String getName(){
return name;
}
public String getSex(){
return sex;
}
public void setGrade(int g){
this.grade = g;
}
public String getStudentId(){
return studentId;
}
}
这里面定义了一些得到当前学生对象数据的一些get方法,和成绩修改的set方法,代码很简单,就不做详细的解答。
就下来就是我们的正文了。
虽然我们暂时不用swing来做界面,但是总得要看的过去吧,所以,先做了一个比较简单的界面:
System.out.println("***************");
System.out.println("*欢迎来到学生管理系统 *");
System.out.println("*1:增加学生 *");
System.out.println("*2:删除学生 *");
System.out.println("*3:修改成绩 *");
System.out.println("*4:查询成绩 *");
System.out.println("***************");
System.out.println("您想选择的操作是:");
这里可以看到,我们的是用一个1234来选择项目,说以不得不讲一下Java如何获取到键盘所输入的数据---------Scanner ,要使用这个,首先需要import进来一个包:
例如这里:
import java.util.*;
之后的两行代码搞定输入:
Scanner sc = new Scanner(System.in);
int choice = sc.nextInt();
接下来就是各个功能的实现:
package test;
import java.util.*;
import bean.Student;
public class Manager {
static ListStudent StudentList = new LinkedListStudent();
public static void main(String[] agrs){
select(StudentList);
}
private static void select(ListStudent StudentList ){
System.out.println("***************");
System.out.println("*欢迎来到学生管理系统 *");
System.out.println("*1:增加学生 *");
System.out.println("*2:删除学生 *");
System.out.println("*3:修改成绩 *");
System.out.println("*4:查询成绩 *");
System.out.println("***************");
System.out.println("您想选择的操作是:");
Scanner sc = new Scanner(System.in);
int choice = sc.nextInt();
switch(choice){
//增加学生
case 1:
System.out.print("请输入学生的姓名:");
Scanner Sname = new Scanner(System.in);
String name = Sname.nextLine();
System.out.print("请输入学生的性别:");
Scanner Ssex = new Scanner(System.in);
String sex = Ssex.nextLine();
System.out.print("请输入学生的学号:");
Scanner SId = new Scanner(System.in);
String studentId = SId.nextLine();
System.out.print("请输入学生的成绩:");
Scanner Sgrade = new Scanner(System.in);
int grade = Sgrade.nextInt();
StudentList.add(new Student(name,studentId,sex,grade));
System.out.println("添加成功!!!!!");
select(StudentList);
break;
//删除学生成绩
case 2:
System.out.print("请告诉我需要删除学生的学号:");
Scanner Sid = new Scanner(System.in);
String SstudentId = Sid.nextLine();
boolean isfindDelete = false;
for (int i = 0; i StudentList.size(); i++) {
if(SstudentId.equals(StudentList.get(i).getStudentId())){
System.out.println("发现了该学生,正在删除...");
StudentList.remove(i);
System.out.println("删除成功!!!");
isfindDelete =true;
}
}
if(!isfindDelete){
System.out.println("抱歉,没有找到");
}
select(StudentList);
break;
//修改学生成绩
case 3:
System.out.print("请告诉我需要修改成绩学生的学号:");
Scanner GId = new Scanner(System.in);
String GstudentId = GId.nextLine();
boolean isfindChange = false;
for (int j = 0; j StudentList.size(); j++) {
if(GstudentId.equals(StudentList.get(j).getStudentId())){
System.out.println("发现了该学生,正在修改...");
System.out.println("学生原成绩为"+StudentList.get(j).getGrade());
System.out.print("请输入修改后学生的成绩:");
Scanner Ggrade = new Scanner(System.in);
int grade2 = Ggrade.nextInt();
StudentList.get(j).setGrade(grade2);
System.out.println("修改成功!!!");
isfindChange =true;
}else{
}
}
if(!isfindChange){
System.out.println("抱歉,没有找到");
}
select(StudentList);
break;
//查看学生成绩
case 4:
System.out.print("请告诉我需要查询学生的学号:");
Scanner CId = new Scanner(System.in);
String CstudentId = CId.nextLine();
boolean isfindData = false;
for (int i = 0; i StudentList.size(); i++) {
if(CstudentId.equals(StudentList.get(i).getStudentId())){
System.out.println("名字:"+StudentList.get(i).getName());
System.out.println("性别:"+StudentList.get(i).getSex());
System.out.println("学号:"+StudentList.get(i).getStudentId());
System.out.println("成绩:"+StudentList.get(i).getGrade());
isfindData = true;
}
}
if(!isfindData){
System.out.println("抱歉,没有找到");
}
select(StudentList);
break;
default:
System.out.println("您输入的数字有误,请重新输入:");
break;
}
}
}
可以看见,我把所有的实现过程全部放在select();方法中了,这样可以避免我选择完了一个操作后不能继续其他操作。大部分的操作都是依靠for循环来遍历操作,方便快捷。
需要完整代码,谢谢大家!需要Java的学生管理系统,具体的在下面的说明问题,有需要要求。按着要求来就行
public class Course {
private String name;
private float score;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public float getScore() {
return score;
}
public void setScore(float score) {
this.score = score;
}
public Course(String name, float score) {
this.name = name;
this.score = score;
}
public String toString() {
return this.name + ":" + this.score;
}
}
public class Student {
private long id;
private String name;
private int age;
private boolean sex;
public String toString() {
String sex = "女";
if (this.sex == true) {
sex = "男";
}
return String.format("姓名:%s,性别:%s,联系电话:%s,课程信息:%s,课程信息:%s", this.name, sex, this.phone, this.subject.toString());
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public boolean isSex() {
return sex;
}
public void setSex(boolean sex) {
this.sex = sex;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public Course[] getSubject() {
return subject;
}
public void setSubject(Course[] subject) {
this.subject = subject;
}
private String phone;
private Course[] subject;
public Student(long i, String n, int a, boolean s, String p) {
this.id = i;
this.name = n;
this.age = a;
this.sex = s;
this.phone = p;
}
}
import java.util.ArrayList;
public class Cmanage {
private ArrayListStudent students;
//插入
public void addStudent(Student student) {
students.add(student);
}
//删除
public void delStudent(Student student) {
students.remove(student);
}
//查询
public void queryStudent() {
System.out.printf("一共有%d个学生", students.size());
for (Student student : students) {
System.out.println(student.toString());
}
}
//修改
public void updateStudent(long i, String n, int a, boolean s, String p)
{
//以姓名做为唯一标识
for(int j=0;jstudents.size();j++)
{
if (students.get(j).getName().equals(n))
{
students.get(j).setId(i);
students.get(j).setAge(a);
students.get(j).setSex(s);
students.get(j).setPhone(p);
}
}
}
}
文章题目:教学管理系统java代码,java课程管理系统源码
网站URL:http://hbruida.cn/article/heoesg.html