用c++过了 改成java可过样例,是不是有什么格式错误?

import java.io.IOException;
import java.util.*;

public class Main {
public static void main(String args[]) throws IOException{
Scanner in=new Scanner(System.in);

String nameString;
int grade;
int classGrade;
String isWestern;
String isCadres;
int essayNum;

String name=null;
int Max=0;
int total=0;
int tempNum=0;

int n;
n=in.nextInt();
for(int i=0;i<n;i++){
nameString=in.next();
grade=in.nextInt();
classGrade=in.nextInt();
isCadres=in.next();
isWestern=in.next();
essayNum=in.nextInt();

StudentInfo temp=new StudentInfo(nameString, grade, classGrade, isWestern, isCadres, essayNum);
tempNum=temp.getAmount();
if(tempNum>Max){
Max=tempNum;
name=nameString;
}
total+=tempNum;
}
System.out.println(name);
System.out.println(Max);
System.out.print(total);

}
public static class StudentInfo {
private String name;
private int grade;
private int classGrade;
private String isWestern;
private String isCadres;
private int essayNum;

public StudentInfo(String name,int grade,int classGrade,String isWestern,String isCadres,int essayNum){
this.name=name;
this.grade=grade;
this.classGrade=classGrade;
this.isCadres=isCadres;
this.isWestern=isWestern;
this.essayNum=essayNum;
}

public String getName(){
return this.name;
}

public int getAmount(){
int sum=0;
if (grade > 80){
if (essayNum >= 1){
sum += 8000;
}
if (grade > 85){
if (classGrade > 80){
sum += 4000;
}
if (isWestern.equals("Y")){
sum += 1000;
}
if (grade > 90){
sum += 2000;
}
}
}
if (classGrade > 80&&isCadres.equals("Y")){
sum += 850;
}
return sum;
}
}
}

1 条评论

  • 1

信息

ID
1001
难度
5
分类
模拟 点击显示
标签
递交数
39260
已通过
12791
通过率
33%
被复制
129
上传者