java的课程表求解
我该怎么存储中文输入并输出,怎么最简便方法使输出表格整齐?怎么分成几个类?其实为什么要分几个类我也不知道?程序代码:
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package reportcard; import java.util.Scanner; import java.text.*; /** * * @author Administrator */ public class Reportcard { /** * @param args the command line arguments */ public static void main(String[] args) { String [][]s3=new String [100][3]; int [][]s4=new int [100][6]; int i=1; String a; System.out.println("现在要创建一个成绩单:"); Scanner input =new Scanner(System .in);// TODO code application logic here System.out.print("请输入课程名称:"); String s =input.next(); System.out.print("请输入教师名称:"); String s1 =input.next(); System.out.print("请输入班级名称:"); String s2 =input.next(); System.out.print("请输入学生人数:"); int n=input.nextInt(); chengji(s3,s4,n); System.out.print("成绩单已创建成功!!\n请输入指令:\n查看成绩单:请输入“1”\n查询成绩:请输入“2”\n退出选择:请输入“0”\n"); caidan(s3,s4,s,s1,s2,n); } public static void caidan(String s3[][],int s4[][],String s,String s1,String s2,int n){ Scanner input =new Scanner(System .in); int i=1; while(i==1){ String a =input.nextLine(); switch(a){ case"1":{chengjidan(s3,s4,s,s1, s2,n);break;} case"2":{chaxunchengji(s3,s4,n);break;} case"0":{i=0;break;} } System.out.print("请输入指令:\n查看成绩单请输入“1”\n查询成绩请输入“2”\n退出选择请输入“0”\n"); } } public static void chengji(String s[][],int s2[][],int n){ Scanner input =new Scanner(System .in); for(int i=1;i<=n;i++){ System.out.print("请输入第"+i+"个学生的学号:"); s[i][1]=input.nextLine(); System.out.print("请输入学生姓名:"); s[i][2]=input.nextLine(); chengji2(s2,i); } } public static void chengji2(int s2[][],int i){ Scanner input =new Scanner(System .in); System.out.print("请输入学生考勤成绩:"); s2[i][1]=input.nextInt(); System.out.print("请输入学生测验成绩:"); s2[i][2]=input.nextInt(); System.out.print("请输入学生作业成绩:"); s2[i][3]=input.nextInt(); System.out.print("请输入学生期末成绩:"); s2[i][4]=input.nextInt(); s2[i][5]=s2[i][4]+s2[i][3]+s2[i][2]+s2[i][1]+s2[i][0]; } public static void chengjidan(String s[][],int s2[][],String a,String b,String c,int n){ int []x=new int [5]; DecimalFormat df=new DecimalFormat("#.##"); double e; System.out.println(" 期末考试成绩单 "); System.out.println("课程 :"+a); System.out.println("教师 :"+b); System.out.println("班级 :"+c); System.out.println("学号 姓名 考勤 小测 作业 期末 总评 "); for(int i=1;i<=n;i++){ System.out.printf("%-11s%-9s%-9s%-9s%-9s%-9s%-9s\n",s[i][1],s[i][2],s2[i][1],s2[i][2],s2[i][3],s2[i][4],s2[i][5]); } for(int i=0;i<5;i++){ x[i]=0; } for(int i=1;i<=n;i++){ if(s2[i][5]>=90) x[0]++; else if(s2[i][5]<90&&s2[i][5]>=80) x[1]++; else if(s2[i][5]<80&&s2[i][5]>=70) x[2]++; else if(s2[i][5]<70&&s2[i][5]>=60) x[3]++; else x[4]++; } System.out.println("成绩区段 人数 百分比"); e=x[0]*1.0/n; String st=df.format(e); System.out.printf("90~100 %-15s",x[0]); System.out.println(st); e=x[1]*1.0/n; System.out.printf("80~89 %-15s",x[1]); st=df.format(e); System.out.println(st); e=x[2]*1.0/n; System.out.printf("70~79 %-15s",x[2]); st=df.format(e); System.out.println(st); e=x[3]*1.0/n; System.out.printf("60~69 %-15s",x[3]); st=df.format(e); System.out.println(st); e=x[4]*1.0/n; System.out.printf("0~60 %-15s",x[4]); st=df.format(e); System.out.println(st); } public static void chaxunchengji(String s[][],int s2[][],int n){ String a; int i; Scanner input =new Scanner(System .in); System.out.print("查询学生的学号:"); a =input.nextLine(); for( i=1;i<=n;i++){ if(a.equals(s[i][1])) {System.out.println("学号 姓名 考勤 小测 作业 期末 总评 "); System.out.printf("%-11s%-9s%-9s%-9s%-9s%-9s%-9s\n",s[i][1],s[i][2],s2[i][1],s2[i][2],s2[i][3],s2[i][4],s2[i][5]); break; } } if(i>n) System.out.println("没有此人,请确认输入是否正确"); } }