javaは学生の成績管理システムを実現します.


package labReport;

import java.util.Scanner;

public class StudentInformation {
	public String name = new String();
	public long stuId = 0L;
	public String lesson_1 = new String();
	public String lesson_2 = new String();
	public float scoreOfLesson_1 = 0f;
	public float scoreOfLesson_2 = 0f;
	public float sum = 0f;
	public StudentInformation next = null;;
	
	public StudentInformation(String name, long stuId, String lesson_1, String lesson_2, float scoreOfLesson_1, float scoreOfLesson_2){
		this.lesson_1 = lesson_1;
		this.lesson_2 = lesson_2;
		this.name = name;
		this.scoreOfLesson_1 = scoreOfLesson_1;
		this.scoreOfLesson_2 = scoreOfLesson_2;
		this.stuId = stuId;
		this.sum = this.scoreOfLesson_1 + this.scoreOfLesson_2;
	}
	public StudentInformation(Scanner input){
		this(input.next(), input.nextLong(), null, null, input.nextFloat(), input.nextFloat());
	}
	
}
package labReport;

import java.util.Scanner;

public class StudentList {
	public StudentInformation head = null;
	private Scanner input = new Scanner(System.in);
	public float sumLesson_1 = 0f, sumLesson_2 = 0f;
	public StudentInformation maxStuSc_1, minStuSc_1;
	public StudentInformation minStuSc_2, maxStuSc_2;
	public StudentList(){
		head = new StudentInformation(null, 0, null, null, 0, 0);
	}
	
	public StudentList(int lenght){
		this();
		int i = 0;
		for(i = 0; i < lenght; i++)
			insert();
	}
	public void change(long id){
		float newScore_1 = 0f, newScore_2 = 0f;
		StudentInformation p = head;
		while(p != null){
			if(p.stuId == id){
				System.out.println("
:\t \t "); while(! input.hasNextFloat()){ input.next(); System.out.println("
, !"); System.out.println("
:\t \t "); } newScore_1 = input.nextFloat(); while(! input.hasNextFloat()){ input.next(); System.out.println("
, !"); System.out.println("
:\t \t "); } newScore_2 = input.nextFloat(); p.scoreOfLesson_1 = newScore_1; p.scoreOfLesson_2 = newScore_2; } p = p.next; } } public void insert() {// StudentInformation p = head; StudentInformation s = new StudentInformation(input); s.next = p.next; p.next = s; } public void remove(long id) throws Exception{// StudentInformation p = head.next; int j = -1; while(p.next != null && j < lenght() - 1){ if(p.stuId == id) break; p = p.next; j++; } if(j > lenght() || p == null){ throw new Exception(" "); } p.next = p.next.next; } public int lenght() {// int lenght = 0; StudentInformation p = head.next; while(p != null){ lenght++; p = p.next; } return lenght; } public void rank(){// StudentInformation p, q, snap1, snap2; while(true){ int judge = 0; p = head; q = p.next; while(p.next != null && q.next != null){ if(p.next.sum < q.next.sum){ judge = 1; snap1 = p.next; snap2 = q.next; p.next = snap2; snap1.next = snap1.next.next; snap2.next = snap1; } if(q.next == null || p.next == null) break; p = p.next; q = q.next; } if(judge == 0) break; } } public void findStudent(long id) throws Exception{// StudentInformation p = head.next; while(p != null && p.stuId != id) p = p.next; if(p == null){ throw new Exception(" !"); } System.out.println(" :" + p.name + "\t" + head.lesson_1 + " :" + (int)(p.scoreOfLesson_1 * 10) / 10.0 + "\t" + head.lesson_2 + " :" + (int)(p.scoreOfLesson_2 * 10) / 10.0); } public void check(){// StudentInformation p = head.next; System.out.println(" \t \t \t" + " \t \t \t "); while(p != null){ System.out.println(p.name + "\t" + p.stuId + "\t" + head.lesson_1 + "\t" + (int)(p.scoreOfLesson_1 * 10) / 10.0 + "\t" + head.lesson_2 + "\t" + (int)(p.scoreOfLesson_2 * 10) / 10.0 + "\t" + (int)(p.sum * 10) / 10.0); p = p.next; } } public void statistics(){ StudentInformation p = head.next; float minScoreOfLesson_2 = 100f, minScoreOfLesson_1 = 100f; float maxScoreOfLesson_2 = 0f, maxScoreOfLesson_1 = 0f; while(p != null){ sumLesson_1 += p.scoreOfLesson_1; sumLesson_2 += p.scoreOfLesson_2; minStuSc_1 = minScoreOfLesson_1 < p.scoreOfLesson_1 ? minStuSc_1 : p; maxStuSc_1 = maxScoreOfLesson_1 > p.scoreOfLesson_1 ? maxStuSc_1 : p; maxStuSc_2 = maxScoreOfLesson_2 > p.scoreOfLesson_2 ? maxStuSc_2 : p; minStuSc_2 = minScoreOfLesson_2 < p.scoreOfLesson_2 ? minStuSc_2 : p; minScoreOfLesson_1 = minStuSc_1.scoreOfLesson_1; minScoreOfLesson_2 = minStuSc_2.scoreOfLesson_2; maxScoreOfLesson_1 = maxStuSc_1.scoreOfLesson_1; maxScoreOfLesson_2 = maxStuSc_2.scoreOfLesson_2; p = p.next; } System.out.println("
\t \t
\t \t \t
"); System.out.println("" + maxStuSc_1.scoreOfLesson_1 + "\t" + maxStuSc_1.name + "\t" + maxStuSc_1.stuId + "
" + minStuSc_1.scoreOfLesson_1 + "\t" + minStuSc_1.name + "\t" + minStuSc_1.stuId); System.out.println((int)((sumLesson_1 / lenght()) * 10) / 10.0); System.out.println("
\t \t
\t \t \t
"); System.out.println(maxStuSc_2.scoreOfLesson_2 + "\t" + maxStuSc_2.name + "\t" + maxStuSc_2.stuId + "
" + minStuSc_2.scoreOfLesson_2 + "\t" + minStuSc_2.name + "\t" + minStuSc_2.stuId); System.out.println((int)((sumLesson_2 / lenght()) * 10) / 10.0); } } package labReport; import java.util.Scanner; public class TestReport { static{ System.out.println(" ( )!"); System.out.println(" , !"); System.out.print(" :"); } public static void main(String[] args){ StudentList list = new StudentList(); Scanner input = new Scanner(System.in); int capita = 0;// int i = 0; list.head.lesson_1 = input.next(); list.head.lesson_2 = input.next(); System.out.println(" !"); while(! input.hasNextInt()){ input.next(); System.out.println(" , :"); System.out.println(" !"); } capita = input.nextInt(); System.out.println(" \t \t \t" + list.head.lesson_1 + " \t" + list.head.lesson_2 + " "); for(i = 0; i < capita; i++) list.insert(); menu(list); input.close(); } @SuppressWarnings("resource") public static void menu(StudentList list){ Scanner input = new Scanner(System.in); while(true){ System.out.println(" !"); System.out.println("1、 \t2、 \t3、 \t4、" + " \t5、 \t6、 \t7、 "); while(! input.hasNextInt()){ input.next(); System.out.println(" , !"); System.out.println("1、 \t2、 \t3、 \t4、" + " \t5、 \t6、 \t7、 "); } switch(input.nextInt()){ case 1: System.out.println(" \t \t \t" + list.head.lesson_1 + " \t" + list.head.lesson_2 + " "); list.insert(); System.out.println(" !"); break; case 2: System.out.println(" !"); try { while(! input.hasNextInt()){ input.next(); System.out.println(" , !"); } list.remove(input.nextLong()); } catch (Exception e) { e.printStackTrace(); } System.out.println(" !"); break; case 3: System.out.println(" !"); try { while(! input.hasNextInt()){ input.next(); System.out.println(" , !"); } list.findStudent(input.nextLong()); } catch (Exception e) { e.printStackTrace(); } System.out.println(" !"); break; case 4: System.out.println(" !"); while(! input.hasNextInt()){ input.next(); System.out.println(" , !"); } list.change(input.nextLong()); System.out.println(" !"); break; case 5: list.rank(); list.check(); System.out.println(" !"); break; case 6: list.statistics(); System.out.println(" !"); break; case 7: System.out.println(" !"); System.exit(0); break; default: try { System.out.println(" !
"); Thread.sleep(10000); } catch (InterruptedException e) { e.printStackTrace(); } break; } } } }