• 实训


     1 package data;
     2 
     3 import java.util.Scanner;
     4 class student
     5 {
     6     String name;
     7     char sex;
     8     int age;
     9     String id;
    10     int a[]= new int [5];
    11     public student(String name,char sex,int age,String id,int a[])
    12     {
    13         this.name=name;
    14         this.sex=sex;
    15         this.age=age;
    16         this.id=id;
    17         this.a=a;
    18     }
    19     public void outdata()
    20     {
    21         System.out.println(name+" "+sex+" "+age+" "+id+" "+a[0]+" "+a[1]+" "+a[2]+" "+a[3]+"+a[4");
    22     }
    23     public int aver()
    24     {
    25         int sum=0;
    26         for(int i=0;i<5;i++)
    27         {
    28             Object[] stu;
    29             sum+=stu[i].a[i];
    30         }
    31     }
    32     
    33     
    34 }
    35 public class Taxtstudent 
    36 {
    37     public static void main(String[] args)
    38     {
    39         Scanner in=new Scanner (System.in);
    40         System.out.println("请输入您要录入的学生数目:");
    41         int stunumber = in.nextInt();
    42         student stu[] =new student[stunumber];
    43         System.out.println("请录入学生信息:");
    44         for(int i=0;i<stu.length;i++)
    45         {
    46             System.out.println("请分别输入第"+(i+1)+"位同学的姓名、性别、年龄、身份证号码和五门成绩:");
    47             String name=in.next();
    48             String ch=in.next();
    49             char sex=ch.charAt(0);
    50             int age= in.nextInt();
    51             String id=in.next();
    52             int[] a = null;
    53             for(int j=0;j<5;j++)
    54             {
    55                 //Scanner i3=new Scanner(System.in); 
    56                 
    57                 
    58                 a[i]=in.nextInt();
    59             }
    60             stu[i]= new student(name,sex,age,id,a);
    61             System.out .println();
    62             
    63         }
    64         System.out.println();
    65         for(int i=0;i<stu.lenght;i++)
    66         {
    67             System.out.println("第"+(i+1)+"位学生的姓名、性别、年龄、身份证号码和五门成绩!");
    68             stu[i].outdata();
    69             System.out.println("平均成绩为:");
    70         }
    71         
    72     }
    73 
    74 }
  • 相关阅读:
    udev 禁止某些驱动自动加载
    AT91SAM9XEK ramdisk 启动笔记
    MTD 工具使用
    kmp问题
    野指针 空指针 通用指针
    manacher算法实现
    manacher算法
    strcpy和strlen
    冒泡排序
    C++的重载(overload)与重写(override
  • 原文地址:https://www.cnblogs.com/zhangkaiz/p/10735076.html
Copyright © 2020-2023  润新知