慢慢理解一下先把
程序代码:
package searchstudent; import java.lang.reflect.Array; import java.util.Arrays; import java.util.Scanner; /** * 成绩统计 * * */ public class score { public static Scanner scann=new Scanner(System.in); public static void main(String[] args) { //输入课程数 int x; lei l=new lei(); System.out.println("课程数:"); x=scann.nextInt(); String []km=new String[x]; for(int i=0;i<km.length;i++) { System.out.println("输入科目:"); km[i]=scann.next(); } l.setKemu(km); int [] cj=new int[x]; //输入成绩 for(int i=0;i<km.length;i++){ System.out.println("输入"+km[i]+"成绩:"); cj[i] =scann.nextInt(); } l.setChengji(cj); System.out.println(Arrays.toString(l.getKemu())); System.out.println(Arrays.toString(l.getChengji())); } }
程序代码:
package searchstudent; public class lei { private int []chengji; private String [] kemu;//存储数据; public int[] getChengji() { return chengji; } public void setChengji(int[] chengji) { this.chengji = chengji; } public String[] getKemu() { return kemu; } public void setKemu(String[] kemu) { this.kemu = kemu; } }
感觉写的很麻烦!!!!