zoukankan      html  css  js  c++  java
  • 实验七

    源代码:

    import java.util.Scanner;
    public class Student {
        public int i=0;
     public String xing,name,zy,nj,address;
     public double date,score;
     public String xuehao;
     Scanner shuru=new Scanner(System.in);
     public Student(){}
     public Student(String xing,String name,String zy,String nj,String address,double date,double score)
     {
      this.xing=xing;
      this.name =name;
      this.zy=zy;
      this.nj=nj;
      this.address=address;
      this.date=date;
      this.score=score;
     }
     void name_chazhao(String temp) {
       System.out.println(name+" "+zy+" "+nj+" "+address+" "+date+" "+score+" "+xuehao);
     }
     void date_chazhao(double temp) {
        System.out.println(name +" "+zy+" "+nj+" "+address+" "+date+" "+score+" "+xuehao);
     }
     void address_chazhao(String temp) {
       System.out.println(name+" "+zy+" "+nj+" "+address+" "+date+" "+score+" "+xuehao);
     }
     public static void main(String[] args) {
      int i,j=1,t=1,w=0;
      int length;
      Student[] stu=new Student[5];//("李","李会通","网络工程","17级","海南万宁",1998,100);
      stu[0]=new Student("李","李会通","网络工程","17级","海南万宁",1998,100);
      stu[1]=new Student("钟","钟若文","网络工程","17级","广西南宁",1997,100);
      stu[2]=new Student("马","马元斌","网络工程","17级","青海西宁",1999,100);
      stu[3]=new Student("白","白云超","网络工程","17级","青海西宁",1999,100);
      stu[4]=new Student("牛","牛明旺","生物工程","17级","河北武安",1998,92);
      String temp=stu[0].zy;
      int []fuzhu=new int[100];
      String []zhuanye=new String[100];
      zhuanye[0]=stu[0].zy;
      length=stu.length;
      for(i=0;i<stu.length;i++){
       if(stu[i].zy!=temp){
        fuzhu[j]=j;
        zhuanye[j++]=stu[i].zy;
       }
      }
      for(i=0;i<length;i++){
       stu[i].xuehao="20";
       char [] stringArr =stu[i].zy.toCharArray();
       for(j=0;j<stringArr.length;j++){
        if(stringArr[j]>='0'&&stringArr[j]<='9'){
         stu[i].xuehao+=stringArr[j];
        }
        for(w=0;w<zhuanye.length;w++){
         if(stu[i].zy==zhuanye[w]){
          stu[i].xuehao+=fuzhu[w];
          break;
         }
        }
       }
       stu[i].xuehao+=t++;
      }
      Scanner shuru=new Scanner(System.in);
      int choice=1;
      while(choice!=0){
       System.out.println("0.退出系统 1.按姓名查找 2.按年份查找 3.按省市查找 4.统计成绩");
       System.out.println("请输入你的选择:");
       choice=shuru.nextInt();
      switch(choice){
      case 0:System.exit(0);
      case 1:System.out.println("请输入查找的姓:");
      temp=shuru.next();
      for(i=0;i<stu.length;i++) {
          if(stu[i].xing.equals(temp)){
       stu[i].name_chazhao(temp);
          break;
          }
      }//for循环的括号
      break;
      case 2:System.out.println("请输入查找的年份:");
      double temp2=shuru.nextDouble();
      for(i=0;i<stu.length;i++){
       if(stu[i].date==temp2) {
        stu[i].date_chazhao(temp2);
       }
      }
      break;
      case 3:System.out.println("请输入查找的省市:");
      temp=shuru.next();
      for(i=0;i<stu.length;i++){
       if(stu[i].address.contains(temp)==true) {
        stu[i].address_chazhao(temp);
       }
      }
      break;
      case 4:double []num=new double[300];
      for(i=0;i<300;i++){num[i]=0;}
      for(i=0;i<stu.length;i++){
       for(j=0;j<zhuanye.length;j++){
        if(stu[i].zy==zhuanye[j]){
         num[fuzhu[j]]+=stu[i].score;
        }
       }
      }
      for(i=0;i<num.length;i++){
       if(num[i]!=0){
       System.out.print(zhuanye[i]);
       System.out.println("班的总分是:"+num[i]);
       }
      }
      break;
      }//选择结构的括号
      }
     }
    }

  • 相关阅读:
    (winform cookie)如何向某网址Post信息,并得到CookieContainer以便以后直接通过验证
    NBear官方MSN群
    NBear 支持基于操作符重载的强类型Where及OrderBy查询
    NBear视频 0.1 NBear类库结构及功能简介[发布时间:9/5]
    NBear 使用Entity Configurator设置实体元数据、生成数据库创建脚本
    ORM中的继承关系映射全解——单表继承体系、一实体一具体表、一实体一扩展表、接口映射
    实例解析继承体系重构及ORM映射
    NBearV2.1.0,新增Oracle和MySql Db Provider,诚征测试
    NBear视频 1.1 实体定义基础[发布时间:9/5]
    使用主动实体(ActiveEntity)简化继承体系映射类的写操作
  • 原文地址:https://www.cnblogs.com/myb1128/p/10822389.html
Copyright © 2011-2022 走看看