npc一h的gravatar头像
npc一h 2017-10-22 11:16:34

java控制台实现简单的学生管理系统

java控制台实现简单的学生管理系统

package studentmanagement;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class test {
	public static void main(String[] args) {
		System.out.println("请输入录入学生个数");
		Scanner recv=new Scanner(System.in);
		int n=Integer.parseInt(recv.nextLine());
		System.out.println("请输入学生名字和成绩");
		List<Student> list=new ArrayList<Student>();
		for(int i=1;i<=n;i++) {
			Student a=new Student();
			System.out.println("第"+i+"个学生姓名");
			String name=recv.nextLine();
			a.setName(name);
			System.out.println("第"+i+"个学生成绩");
			double score=recv.nextDouble();
			a.setScore(score);
			 recv.nextLine();
			list.add(a);
		}
		for(Student a:list) {
			System.out.println(a.getName()+"成绩为"+a.getScore());
		}
	}
}
package studentmanagement;

public class Student extends person {
	private double score;

	public double getScore() {
		return score;
	}

	public void setScore(double score) {
		this.score = score;
	}
	
}
package studentmanagement;

public class person {
	private String name;

	public String getName() {
		return name;
	}

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

打赏

顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友