fork download
  1. /* My Java program */
  2. import java.util.*;
  3. import java.lang.*;
  4. import java.io.*;
  5. class MyLab
  6. { public static void main (String[] args) throws java.lang.Exception
  7. { final double K=22.50; final double L=7.5; double x=0.0; double a, b; double y=0.0;
  8. System.out.println("Plese enter value for X\n");
  9. Scanner in = new Scanner(System.in);
  10. x=in.nextDouble();
  11. System.out.println(x);
  12. in.close();
  13. a=Math.pow((Math.pow(K,(-0.5))-L*Math.sqrt(x+2.84)),2);
  14. System.out.println("Result is A="+a);
  15. b = -Math.log10(x) * Math.exp(x);
  16. System.out.println("Result is B="+b);
  17. if (a > b) {
  18. y = (4 * a + 3 * b) / (Math.pow(a, 2) + Math.pow(b, 2));
  19. }
  20. if (a<=b)
  21. {
  22. y = Math.abs(a - b);
  23. }
  24. System.out.println("Result is Y="+y);
  25. }
  26. }
Success #stdin #stdout 0.24s 58884KB
stdin
-0.414
stdout
Plese enter value for X

-0.414
Result is A=131.5815003020345
Result is B=NaN
Result is Y=0.0