编写出java程序要求:学生有若干门学科 每门学科有若干次考试将考试分数相加的总分评估等第学科评估标准如下: 
低于50   NN 
50 - 59  PA
60 - 69  CR
70 - 79  DI
80 - 100 HD
执行的时候会先要求输入有几门学科
然后输入学科1的考试数量
然后依次输入各次考试的分数
最后总分评估出等级在输入学科2的考试次数
然后依次输入各次考试的分数
最后总分评估出等级最后算出学科1和学科2的平均分例如:
Welcome to the student course admin 
How many subjects are there?: 2 
 
Collecting information for subject 0 
How many assessments are there for this subject?: 2 
Please enter assessment : 5 
Please enter assessment : 60 
Subject Mark: 65 - CR 
 
 
Collecting information for subject 1 
How many assessments are there for this subject?: 3 
Please enter assessment : 10 
Please enter assessment : 25 
Please enter assessment : 40 
Subject Mark: 75 - DI 
 
Student Average Mark is 70 文件名为course.java 
最好使用到evaluate(),getValidNum(),printMarkGrade()
调用函数evaluateSubject()

解决方案 »

  1.   

    import java.util.Scanner;public class Course
    {   
      private static Scanner sc; 
     public static void main(String []args)
     {
      System.out.print("How many subjects are there:");
      int[][]subjectnum=new int[getsubjectnum()][];
      int[]average=new int[subjectnum.length];
      for(int i=0;i<subjectnum.length;++i)
      {
       System.out.print("For Subject"+(i+1)+" How many assessments are there:");
       Scanner  sc=getsc();
       int a=sc.nextInt();
       subjectnum[i]=new int[a];
       System.out.print("For Subject"+(i+1)+" plesae enter the assessments the following\n");
       average[i]=kaoping(subjectnum[i].length,i+1);
       System.out.println("For Subject"+(i+1)+" average  is:"+average[i]+"\n");
      }
      System.out.print("There are the average  for all subject\n");
      for(int i=0;i<average.length;++i)
       System.out.print("Subject"+(i+1)+"'s average  is:"+average[i]+"\n");
      System.out.println("The average  for all subject is:"+addsorce(average));
     }
       static int getsubjectnum()
       {   
        Scanner sc=getsc();
        int a=sc.nextInt();
        return a;
       }
       static Scanner getsc()
       {
        if(sc==null){sc=new Scanner(System.in);return sc;}
        else return sc;
       }
       static int kaoping(int n,int j)
       {
        int sum=0,ave;
        Scanner sc=getsc();
        for(int i=0;i<n;++i)
        {
         System.out.print("Please enter subject"+j+"'s No."+(i+1)+"'s assessment :");
         sum+=sc.nextInt();
        }
        ave=sum/n;
        switch(ave/10)
        {
        case 8:System.out.print("The sorce is HD\n");break;
        case 7:System.out.print("The sorce is DI\n");break;
        case 6:System.out.print("The sorce is HD\n");break;
        case 5:System.out.print("The sorce is CR\n");break;
        default:System.out.print("The sorce is NN\n");break;
        }
        return ave;
       }
       static float addsorce(int[]a)
       {
        int sum=0;
        for(int i=0;i<a.length;sum+=a[i],++i);
        return sum/a.length;
       }
    } 怎么将考试平均数改成考试总分