编写一个简单的学生成绩斐然录入程序,要求从键盘输入人数。然后依次输入每个学生的英语,计算机语言和数据库基础的成绩,最后将输入的学生成绩信息全部显示在屏幕上。怎么写啊?帮帮忙!急啊
解决方案 »
- 关于大数操作的问题
- applet
- ### 有关java.nio库Selector的问题 ###
- 继承问题~想了两天了也没法解决,请教高手
- 有什莫parser可以解析TSV-tab separated 文件吗?
- 关于继承,这该如何理解
- 使用UltraEdit的心得
- 如何将jdk和软件打包,制作一个自己的installAnywhere?
- Who can help me? Oh,my java!!!
- 【求助】DWR如何使用spring注解管理的bean
- The method readLine() from the type DataInputStream is deprecated
- 关于DataInputStream的简单问题
这个就是接收从键盘输入的信息,然后你吧接收到的东西处理一下就可以了
private String[] name = new String[5]; //姓名
private double[] score = new double[5]; //学分
private double[] sum = new double[5] ; //学分的总成绩和
public void input() throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
boolean change = true ;
while(change){
try{
for(int i = 0 ; i <= 4 ; i++){
System.out.println("please input name:");
name[i] = br.readLine();
for(int k = 0 ; k <= 2 ; k ++){
System.out.println("please input"+ i + "score");
score[k] = Integer.parseInt(br.readLine());
}
System.out.println();
sum[i] = score[0]+score[1]+score[2];
}
change = false;
}catch(NumberFormatException e){
System.out.println("Sorry,The Score only can input a number,Please input again");
}
}
}
public void compositor() throws IOException{
FileWriter fw = new FileWriter("F://stud.txt");
BufferedWriter bw =new BufferedWriter(fw);
double temp1 ;
String temp2 ;
for(int i = 0 ; i < 4 ; i++){
for(int j = 1 ; j < 5-i ; j ++){
if(sum[j-1] > sum[j]){
temp1 = sum[j];
sum [j] = sum[j-1];
sum[j-1] = temp1;
temp2 = name[j];
name[j] = name[j-1];
name[j-1] = temp2;
}
}
}
for(int i = 0;i <= 4;i++){
bw.write(name[4-i]);
bw.write(" "+sum[4-i]);
bw.newLine();
}
bw.close();
}
public static void main(String[] args) throws IOException{
Score s = new Score();
s.input();
s.compositor();
}
}
*
* @author
* @version 2010-4-29 上午10:25:40
* @param args
*/
public static void main(String[] args) {
StringBuffer list = new StringBuffer("姓名 英语 计算机 数据库\n");
while (true) {
System.out.println("please input a proper integer:");
BufferedReader br = new BufferedReader(new InputStreamReader(
System.in));
try {
String read = br.readLine();
if(read.equals("q"))
{
break;
}
String[] s = read.split(" ");
list.append(s[0]+" "+s[1]+" "+s[2]+" "+s[3]+"\n"); } catch (IOException e) {
e.printStackTrace();
}
}
System.out.println(list.toString());
}
}
int renshu = sc.nextInt();
int [] chengji = new int [renshu];然后遍历 最简单的的思路 因为我也才学没多长时间爱你