• 实验七


    源代码:

    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;
      }//选择结构的括号
      }
     }
    }

  • 相关阅读:
    高能天气——团队博客汇总
    高能天气——团队Scrum冲刺阶段-Day 1-领航
    20172303 2018-2019-1 《程序设计与数据结构》实验三报告
    高能天气——团队作业第二周
    20172303 2018-2019-1《程序设计与数据结构》深度优先遍历
    高能天气——团队作业第一周
    20172322 2018-2019-1《程序设计与数据结构》课程总结
    172322 2018-2019-1 《程序设计与数据结构》哈夫曼编码测试报告
    高能天气——团队Scrum冲刺阶段-Day 3
    172322 2018-2019-1 《程序设计与数据结构》实验三报告
  • 原文地址:https://www.cnblogs.com/myb1128/p/10822389.html
Copyright © 2020-2023  润新知