| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 505 人关注过本帖
标题:希望有空的来看看这个地方怎么执行不过去.划线的地方.谢谢.
只看楼主 加入收藏
okchenpeng
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2008-4-23
收藏
 问题点数:0 回复次数:0 
希望有空的来看看这个地方怎么执行不过去.划线的地方.谢谢.
package 选修课程;

/**
 *
 * @author Administrator
 */
public class Student {
    Course s=new Course();
    String stuName;
   double maxGAP,minGAP;
     static int stuID;
  static int numberCourse;
   static  Course[] list =new Course[numberCourse];
   int [] stuSecor=new int[numberCourse];
      double stuGAP;
              
     
      public  Student()
      {
                  
       list=new Course[numberCourse];
          for(int i=0;i<numberCourse;i++)
              list[i]=new Course();
          stuSecor=new int[numberCourse];
      
      }
      public  int CourseNum()
      {
          return numberCourse;
      }
      public String getstuName()
      {
          return stuName;
      }
      public double getGAP()
      {
          return stuGAP;
      }
      public   static void setCourse( Course[] topic)
      {
          for(int i=0;i<topic.length;i++)
          {
              list[i].CourseName=topic[i].CourseName;
         
              list[i].CourseMark=topic[i].CourseMark;
          }
      }
      public void addstudent(String name,int ID,int[]secor)
      {
          stuName=name;
          stuID=ID;
          for(int i=0;i<secor.length;i++)
              stuSecor[i]=secor[i];
      }
              
     
      public void getstuGAP()
      {
         
          int i=0;
          double smark=0,sumGAP=0,sumsmark=0;
          for(i=0;i<stuSecor.length;i++)
         {
          if(stuSecor[i]>=95)
              smark=4.5;
          else if(stuSecor[i]>=90)
              smark=4.0;
          else if(stuSecor[i]>=85)
              smark=3.5;
          else if(stuSecor[i]>=80)
              smark=3.0;
          else if(stuSecor[i]>=75)
              smark=2.5;
          else if(stuSecor[i]>=70)
              smark=2.0;
          else if(stuSecor[i]>=65)
              smark=1.5;
          else if(stuSecor[i]>=60)
              smark=1.0;
          else
              smark=0;
         sumGAP+=smark*s.getCourseMark();
         sumsmark+=s.getCourseMark();
          }
          stuGAP=sumGAP/sumsmark;  
         
      }
      public void setswap(Student stu1,Student stu2)
      {
          String name;
          int id;
          double GAP;
          int[] secor = new int[Student.numberCourse];
          name=stu1.stuName;
          id=stu1.stuID;
          GAP=stu1.stuGAP;
          for(int i=0;i<Student.numberCourse;i++)
            secor=stu1.stuSecor;
          stu1.stuName=stu2.stuName;
          stu1.stuID=stu2.stuID;
          stu1.stuGAP=stu2.stuGAP;
         
          for(int i=0;i<Student.numberCourse;i++)
         
              stu1.stuSecor=stu2.stuSecor;
          stu2.stuGAP=GAP;
          stu2.stuID=id;
          stu2.stuName=name;
         
          for(int i=0;i<Student.numberCourse;i++)
              stu2.stuSecor=secor;
         
      }
      public void maxminGAP(Student[] stu)
          {
          double max,min;
         
          if(stu.length==0)
              min=max=-1;   
          min=max=stu[0].stuGAP;
          for(int i=0;i<stu.length;i++)
          {
              if(max<stu[i].stuGAP)
                  max=stu[i].stuGAP;
              if(min>stu[i].stuGAP)
                  min=stu[i].stuGAP;   
          }  
          maxGAP=max;
          minGAP=min;
      }
      public double getmin()
      {
      
          return minGAP;
      }
      public double getmax()
      {
         
          return maxGAP;
      }
      public void SortGPA( Student[] stu)
            {
                int i, j, pos;
                for(i=0;i<stu.length-1;i++)
                {
                    for (j = (pos = i); j < stu.length; j++)
                        if (stu[pos].stuGAP< stu[j].stuGAP)
                            pos = j;
                    if (pos != i)
                        stu[i].setswap( stu[i], stu[pos]);
                }
      }
}
               package 选修课程;
import java.util.*;
/**
 *
 * @author Administrator
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
    Course r=new Course();
        Student t=new Student();
       int Num, Mark,Id;
       String  Name;
       Scanner in=new Scanner(System.in);
       System.out.println("请输入学生总人数");
       Num=in.nextInt();
       System.out.println("请输入选修课程总数");
       int k=t.CourseNum();
       k=in.nextInt();
       Student [] stu=new Student[Num];
       for(int i=0;i<Num;i++)
           stu[i]=new Student();
       Course []  tp =new Course [k];
       int [] score  =new int [k];
       for(int i=0;i<k;i++)
       {
           System.out.println("请输入选修课程名称");
           Name=in.next();
           System.out.println("请输入选修课程学分");
           Mark=in.nextInt();
                 
           tp[i]=new Course(Name,Mark);
                  
       }
      
      
     [un]Student.setCourse(tp);     [/un]

 for(int i=0;i<Num;i++)
       {
           System.out.println("请输入学生姓名") ;
           Name=in.next();
           System.out.println("请输入学生学号");
           Id=in.nextInt();
           for(int j=0;j<k;j++)
           {
               System.out.println("请输入学生"+tp[j].getCourseName()+"的成绩");
               score[j]=in.nextInt();
           }
           [un]stu[i].addstudent(Name, Id, score);[/un]        
           
             t.getstuGAP();      
           System.out.println("您的GPA值是"+stu[i].getGAP());
        }
      t.maxminGAP(stu);
     System.out.println("最大GAP是" + t.getmax()+"最小GAP是"+t.getmin());
           t.SortGPA(stu);
         for(int i=0;i<Num;i++)  
           System.out.println("从高到低是"+stu[i].getGAP());
           
                  
       }
      
           
      
    }package 选修课程;

/**
 *
 * @author Administrator
 */
public class Course {
    String CourseName;
    int  CourseMark;
    public Course()
    {
    }
    public Course(String Name,int Mark)
    {
        CourseName=Name;
        CourseMark=Mark;
    }
    public String getCourseName()
    {
        return CourseName;
    }
    public int getCourseMark()
    {
        return CourseMark;
    }
   

}
搜索更多相关主题的帖子: 划线 
2008-04-24 15:03
快速回复:希望有空的来看看这个地方怎么执行不过去.划线的地方.谢谢.
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.033875 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved