altitude92 2022-03-16 13:12 采纳率: 75%
浏览 53
已结题

java提交oj时的错误怎么解决

oj运行总是只有42分,一堆错,但自己运行都和例子符合啊,请问哪里错了
题目

  1. 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");
}

}

  • 写回答

2条回答 默认 最新

  • qq_25376897 2022-03-16 14:30
    关注

    第3个参数Nucleic Acid PCR ,应该是可以Y或者N,其它值才是要输出Error

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 3月16日
  • 已采纳回答 3月16日
  • 创建了问题 3月16日

悬赏问题

  • ¥15 preLaunchTask"C/C++: aarch64- apple-darwin22-g++-14 生成活动 文件”已终止,退出代码为-1。
  • ¥18 关于#贝叶斯概率#的问题:这篇文章中利用em算法求出了对数似然值作为概率表参数,然后进行概率表计算,这个概率表是怎样计算的呀
  • ¥20 C#上传XML格式数据
  • ¥15 elementui上传结合oss接口断点续传,现在只差停止上传和继续上传,各大精英看下
  • ¥100 单片机hardfaulr
  • ¥20 手机截图相片分辨率降低一半
  • ¥50 求一段sql语句,遇到小难题了,可以50米解决
  • ¥15 速求,对多种商品的购买力优化问题(用遗传算法、枚举法、粒子群算法、模拟退火算法等方法求解)
  • ¥100 速求!商品购买力最优化问题(用遗传算法求解,给出python代码)
  • ¥15 虚拟机检测,可以是封装好的DLL,可付费