上一个问题没弄好,看这个

能在电脑上运行,但我不知道哪里出了问题:

import java.util.Scanner;
import java.io.PrintStream;

public class Main {
public static void main(String[] args) throws java.io.UnsupportedEncodingException {
    PrintStream ps = new PrintStream(System.out, true, "UTF-8");
    Scanner in = new Scanner(System.in);
    int x = in.nextInt();
    if(x>=500){ps.print("500");}else
    if(x>500 && x<=3600){ps.print(x*(97/100));}else
    if(x>3600 && x<=14400){ps.print(x*(90/100));}else
    if(x>14400 && x<=30000){ps.print(x*(80/100));}else
    if(x>30000){ps.print(x*(50/100));}
    }
}

1 条评论

  • @ 2019-04-10 22:07:37

    第二个测试用例还没跑过,可以不急着提交,等到第二个跑过了再提交。

    关于分数,如果你试着println(97/100);,你可能就会发现这样表示的问题了。

    然后你可以再试一下println(97.0/100);

    • @ 2019-04-11 09:01:07

      加个double他每次带个零就尴尬了
      ```java
      if(x>3600 && x<=14400){ps.print(x*(90/100));}else

      3700

      3589.0

    • @ 2019-04-11 10:35:25

      这个问题已经解决了

    • @ 2019-04-11 10:39:29
      import java.util.Scanner;
      import java.io.PrintStream;
      
      public class Main {
      public static void main(String[] args) throws java.io.UnsupportedEncodingException {
          PrintStream ps = new PrintStream(System.out, true, "UTF-8");
          Scanner in = new Scanner(System.in);
          int x = in.nextInt();
          if(x<=500){ps.print(x);}else
          if(x>500 && x<=3600){ps.print((int)(x-(x-500)*0.03));}else
          if(x>3600 && x<=14400){ps.print(((int)(x-93)-(x-3600)*(0.1)));}else
          if(x>14400 && x<=30000){ps.print((int)((x-1172)-(x-14400)*(0.2)));}else
          if(x>30000){ps.print((int)((x-4293)-(x-30000)*0.5));}
          }
      }
      
      

      可以帮我看看我的算术哪里出了点问题吗。

    • @ 2019-04-11 11:10:57

      @
      lichengjie
      : 在火车上…没法搞代码…可以请同学先帮你看看哈

  • 1