读书人

哪位高手能帮小弟我看看这个程序小弟

发布时间: 2012-03-06 20:47:55 作者: rapoo

谁能帮我看看这个程序,我用eclipise改了一下结果越改越糟。最后没办法了,请个高手帮帮忙...
//创建一个考生类,包括其属性和方法。
class Ccandidate{
public
String s_name; //考生姓名
String p_cardnumber; //准考证号
String majorname; //报考专业
String s_state; //状态(应届\历届)
int mathscore; //数学成绩
int foreignscore; //外语成绩
int majorscore; //专业课成绩
int policyscore; //政治成绩
int addscore; //总分
public Ccandidate(){
System.out.println("请输入考生的姓名、报考专业、状态(应届/历届):");
try {
s_name=String.valueOf(System.in.read());
majorname=String.valueOf(System.in.read());
s_state=String.valueOf(System.in.read());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

System.out.println("请输入考生的卡号、数学、外语、专业课、政治 成绩:");
try {
p_cardnumber=String.valueOf(System.in.read());
mathscore=System.in.read();
foreignscore=System.in.read();
majorscore=System.in.read();
policyscore=System.in.read();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
addscore=mathscore+foreignscore+majorscore+policyscore;
} //无参数的构造函数
public Ccandidate(String name,String majname,String state,String number,int ms,int fs,int majs,int ps){
s_name = name;
majorname = majname;
s_state = state;
p_cardnumber=number;
mathscore=ms;
foreignscore=fs;
majorscore=majs;
policyscore=ps;
addscore=ms+fs+majs+ps;
} //获取创建时考生的成绩信息方法
}//考生类
//创建一个条件录取类,包括其属性和方法。
class Condition{
public
int math;
int foreign;
int major;
int policy ;
int totalscore;
public Condition() throws IOException{
System.out.println("请输入录取的数学,外语,专业课,政治及总分要求");
math= System.in.read();
foreign=System.in.read();
major=System.in.read();
policy=System.in.read();
totalscore=System.in.read();
}//无参的构造函数
public Condition (int mat, int foe, int mar, int pol){
math = mat;
foreign = foe;
major = mar;
policy = pol;
totalscore = mat+foe+mar+pol;
} // 获取录取分数信息的方法
} // 录取条件类
//创建一个菜单类,实现一个菜单界面的功能。
class Menu{
public Menu(){
System.out.println("\t******* 欢迎进入研究生录取系统*******");
System.out.println("\t---------------------");
System.out.println("\t\t 1.创建记录");
System.out.println("\t\t 2.成绩排名");
System.out.println("\t\t 3.录取情况");
System.out.println("\t\t 4.退出");
System.out.println("\t---------------------");
}
} //菜单类
//创建(主类)信息管理类,完成代码的实现。
public class MangerSystem{
public static void main(String[] args) throws IOException{
int a ;
Menu menu = new Menu();
Ccandidate stu[] = new Ccandidate[20];
Condition con= new Condition();
System.out.println("你的选择是:");
for(int m =1;m<=4;m++){
a = m;


switch(a){
case 1:
//con.getscore( math, foreign, major, policy);
System.out.println("请输入要要创建的记录个数:");
int n = System.in.read();
for(int i = 0; i<= n-1; i++){
stu[i] = new Ccandidate();
}
break;
case 2:
Menu menu1 = new Menu();
System.out.println("你的选择是:");
System.out.println("姓 名 准考证号 数学 英语 专业 政治总分 应届/历届");
System.out.println("成绩如下所示: ");
for(int i = 0; i < stu.length; i++ ){
int j = i;
boolean flag = true;
while(j >= 0 && flag){
if(stu[j].addscore < stu[j+1].addscore)
{
String temp1 = stu[j].s_name;
String temp2 = stu[j].p_cardnumber;
int temp3 = stu[j].mathscore;
int temp4 = stu[j].foreignscore;
int temp5 = stu[j].majorscore;
int temp6 = stu[j].policyscore;
int temp7 = stu[j].addscore;
String temp8 = stu[j].s_state;

stu[j].s_name = stu[j+1].s_name;
stu[j].p_cardnumber = stu[j+1].p_cardnumber;
stu[j].mathscore = stu[j+1].mathscore;
stu[j].foreignscore = stu[j+1].foreignscore;
stu[j].majorscore = stu[j+1].majorscore;
stu[j].policyscore = stu[j+1].policyscore;
stu[j].addscore = stu[j+1].addscore;
stu[j].s_state = stu[j+1].s_state;

stu[j+1].s_name = temp1;
stu[j+1].p_cardnumber = temp2;
stu[j+1].mathscore = temp3;
stu[j+1].foreignscore = temp4;
stu[j+1].majorscore = temp5;
stu[j+1].policyscore = temp6;
stu[j+1].addscore = temp7;
stu[j+1].s_state = temp8;
}
else
flag = false;
j=j-1;
}
for(int k = 0; k < stu.length; k++){
System.out.print(stu[k].s_name +" ");
System.out.print(stu[k].p_cardnumber +" ");
System.out.print(stu[k].mathscore +" ");
System.out.print(stu[k].foreignscore +" ");
System.out.print(stu[k].majorscore +" ");
System.out.print(stu[k].policyscore +" ");
System.out.print(stu[k].addscore +" ");
System.out.println(stu[k].s_state +" ");
}
break;
}
case 3: Menu menu2 = new Menu();
Ccandidate st = new Ccandidate();
if(st.addscore >= con.totalscore){
System.out.println("恭喜你已被录取");
System.out.println("CONGRATUATION:");
}
else
{ System.out.println("抱歉你未被录取");
System.out.println("SORRY");


}
break;
case 4: System.out.println("谢谢使用本系统,再见!");
break;
}
}
}
}



[解决办法]
发错了吧

读书人网 >.NET

热点推荐