Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. package vi;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class vi {
  6.  
  7. public static void main(String[] args) {
  8. Scanner scan = new Scanner(System.in);
  9. double e = 0.9896;
  10. while(true) {
  11. double remainder = 0;
  12. for(int i=0; i<3; i++) {
  13. double v = scan.nextDouble();
  14. double p = scan.nextDouble();
  15. double n = scan.nextDouble();
  16. if(v!=0)
  17. remainder += v/25 * x(p,n);
  18. }
  19. System.out.println("remainder = " + remainder);
  20. System.out.println("ig = " + (e - remainder));
  21. }
  22. }
  23.  
  24. public static double x(double p, double n) {
  25. return (-1)*(p/(p+n)) * Logarithm.log2(p/(p+n)) - (n/(p+n)) * Logarithm.log2(n/(p+n));
  26. }
  27.  
  28. }
  29.  
  30. class Logarithm
  31. {
  32. public static double logb( double a, double b )
  33. {
  34. return Math.log(a) / Math.log(b);
  35. }
  36.  
  37. public static double log2( double a )
  38. {
  39. return logb(a,2);
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement