oj运行总是只有42分,一堆错,但自己运行都和例子符合啊,请问哪里错了
题目
- When using the system, the user is required to input the following information: Student ID, Temperature, Nucleic Acid PCR test result (Y, N). Each parameter has specific requirements: (1) Student ID: an integer number with 8-digit and the first digit can't be "0" (2) Temperature: a float number 35.0<T<45.0 (3) Nucleic Acid PCR test result: string with Y (finished) or N (unfinished) If all the parameters meet the requirements above, the system will output:
Submit successfully
Otherwise, the system will output an error message for different parameters (example):
Error in Student ID
Error in Temperature
Error in Nucleic Acid PCR test
Samples:
input1:
12035336 36.5 Y
Submit successfully
Input2:
1203533 36.5 Y
Error in Student ID
Input3:
1203533 46.5 Y
Error in Student ID and Temperature
这是我的代码
import java.util.Scanner;
import java.util.regex.Pattern;
public class E1 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int StudentID;
float Temperature;
String NucleicAcidPCRtestresult;
StudentID = input.nextInt();
Temperature = input.nextFloat();
NucleicAcidPCRtestresult = input.next();
Pattern pattern = Pattern.compile("^[YN]{1}$");
boolean matches = pattern.matcher(NucleicAcidPCRtestresult).matches();
if (!matches) {
System.out.print("Not valid");
return;
}
if (StudentID >= 10000000 && StudentID <= 99999999 && Temperature >= 35.0 && Temperature <= 45.0 && NucleicAcidPCRtestresult.equals("Y"))
System.out.println("Submit successfully");
if (StudentID >= 10000000 && StudentID <= 99999999 && Temperature >= 35.0 && Temperature <= 45.0 && NucleicAcidPCRtestresult.equals("N"))
System.out.println("Error in Nucleic Acid PCR test");
if (StudentID >= 10000000 && StudentID <= 99999999 && (Temperature < 35.0 || Temperature > 45.0) && NucleicAcidPCRtestresult.equals("Y"))
System.out.println("Error in Temperature");
if ((StudentID < 10000000 || StudentID > 99999999) && Temperature >= 35.0 && Temperature <= 45.0 && NucleicAcidPCRtestresult.equals("Y"))
System.out.println("Error in Student ID");
if ((StudentID < 10000000 || StudentID > 99999999) && (Temperature < 35.0 || Temperature > 45.0) && NucleicAcidPCRtestresult.equals("Y"))
System.out.println("Error in Student ID and Temperature");
if ((StudentID < 10000000 || StudentID > 99999999) && Temperature >= 35.0 && Temperature <= 45.0 && NucleicAcidPCRtestresult.equals("N"))
System.out.println("Error in Student ID and Nucleic Acid PCR test");
if (StudentID >= 10000000 && StudentID <= 99999999 && (Temperature < 35.0 || Temperature > 45.0) && NucleicAcidPCRtestresult.equals("N"))
System.out.println("Error in Temperature and Nucleic Acid PCR test");
if ((StudentID < 10000000 || StudentID > 99999999) && (Temperature < 35.0 || Temperature > 45.0) && NucleicAcidPCRtestresult.equals("N"))
System.out.println("Error in Student ID and Temperature and Nucleic Acid PCR test");
}
}