java - If Statement--related with making integers in percentages of other integers -


I have to write an if statement where I return the string "closed string" when int d is within 10% int e is . I have it now:

  public string game (double D, double E) {if ((d> = 95 * e) || (d & lt; = e * 1.05 )) {Return "close string"; } Other {return "other"; }}   

Examination case

  string game = game (100.0d, 90.0d); Println (game); Game = Games (100.0D, 99.0D); Println (game); Game = Games (100.0D, 100.0D); Println (game);   

Expected output

  Other closed string string closed   

Current Closed string closed string string

Where's the fault?

I'm not sure what you are asking, but I think you want it and its Rather than

  (a & gt; = .95 * b) || (A & lt; = b * 1.05)   

Any number can be because it will be less than 5% below B or 5% below it until it is a real number is.

  (a> = 95 * b) & amp; Amp; (A & lt; = b * 1.05)   

A only + or - 5%

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -