帮忙修改一下这个程序Java

2025-05-16 11:15:17
推荐回答(4个)
回答1:

你这里有好几个大问题!三楼说的对!我在这帮你定义了两个类StudentScore,和Student。能编译通过了! 但我还不是很清楚你要达到什么要求哦!所以我只能帮到这儿了!建议楼主多看看书
import java.io.*;
class StudentScore{ //定义一个StudentScore类
int studentscore=0;
StudentScore(int a){
this.studentscore=a;
}
Student[] a=new Student[studentscore];
void append(Student b){
int i=0;
while(true){
a[i]=b;
i++;
}
}
int search(String s){
for(int i=0;i<10;i++){
if(a[i].b==s){
return Integer.parseInt(s);
}
}
return 0;
}
}
class Student{ //定义一个Student类
String a,b,h;
int c,d,e;
double f;
Student(String a,String b,int c,int d,int e ,double f,String h){
this.a =a;this.b=b;this.c=c;this.d=d;this.e=e;this.f=f;this.h=h;
}
}
public class StudentScoreTest
{
public static void main(String args[])//throws IOException
{
try{
String k,n,s;
int a;
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
//Scanner in=new Scanner(System.in);
System.out.println("请输入最大学生人数:");
s= in.readLine();
a=Integer.parseInt(s);
StudentScore sg=new StudentScore(a);
Student x=new Student("李四","002",86,92,97,3.7,"345");
Student y=new Student("张三","001",90,95,96,4.0,"123");

sg.append(x);
sg.append(y);

while(true)
{
System.out.println("**请选择您的身份**");
System.out.println(" 0.退出系统");
System.out.println(" 1.用户");
System.out.println(" 2.管理员");
System.out.println("***************");
k=in.readLine();
a=Integer.parseInt(k);
if((a==0)||(a==1)||(a==2))
break;
}
while(true)
{
switch(a)
{
case 1:
{
System.out.println("**请输入您的学号**");
n=in.readLine();
if(sg.search(n)!=0){
System.out.println("该学生不存在");
}
while(true){
System.out.println("**请输入您的密码**");
k=in.readLine();
if(k.equals(sg.search(n)))
break;
System.out.println("密码错误,请重新输入。");
}
//Student z1=new Student();
break;
}
case 2:
while(true)
{
System.out.println("**请输入您的密码**");
k=in.readLine();
if(k.equals("1"))
break;
System.out.println("密码错误,请重新输入。");
}
//Admin z2=new Admin(sg.stu);
break;
}
if (a==0)
{
System.out.println("谢谢您使用本系统!");
break;
}
}

}
catch(IOException e){System.out.println("输入错误");}
}
}

回答2:

你这个程序写得太没水平了,
最基本的东西,起码的结构你都不知道,数组的声名你也不会!!!!
强烈建议你多看看基础知识。

回答3:

你都没给出StudentScore,和Student类,怎改或?你这个StudentScoreTest类没有导入必要的库:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

回答4:

SB总是这样问问题,要改成怎么样的也不说