xujinliang 发表于 2010-4-5 23:53:48

简易成绩管理系统

import java.io.*;
import java.util.*;
public class xscjgl
{
        public static int a=5,b=3;
        public static int score[ ] [ ]=new int ;
        static Scanner sc=new Scanner(System.in);
        public static void main(String args[ ]) throws IOException
        {
                cjlr();
                for(;;)
                {
                System.out.println("\n"+"\n"+"成绩查询--------1");
                System.out.println("退出程序--------0");
                System.out.print("请选择:");
                int s=sc.nextInt();
                switch(s)
                {
                        case 1:
                                cjcx();
                                break;
                        case 0:
                                System.out.println("退出程序 OK");
                                break ;
                }
                if(s==0)break;
                }
        }
        public static void cjlr() throws IOException
        {
                int i,j,c,d;
                for(i=0;i<a;i++)
                {
                        score=i+1;
                }
                for(i=0;i<a;i++)
                {
                        d=0;
                        for(j=1;j<=b;j++)
                        {
                                System.out.print("请输入第"+(i+1)+"个学生的第"+j+"门课的成绩");
                                c=sc.nextInt();
                                while(c<0||c>100)
                                {
                                        System.out.print("请重新输入第"+(i+1)+"个学生的第"+j+"门课的成绩");
                                        c=sc.nextInt();
                                }
                                d=d+c;
                                score=c;
                                System.out.println(score);
                                score=d;
                        }
                }
        }
        public static void cjcx() throws IOException
        {
                int e;
                System.out.print("请输入要查找学生的学号");
                e=sc.nextInt();
                while(e<0||e>a)
                {
                        System.out.print("请重新输入要查找学生的学号");
                        e=sc.nextInt();
                }
                for(int j=1;j<=b;j++)
                {
                        System.out.println("学号为"+e+"的学生第"+j+"门课的成绩:"+score);
                }
        }
}
页: [1]
查看完整版本: 简易成绩管理系统