Advertisement
476179

ArithExpress

Sep 30th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. package lessons;
  2.  
  3. public class ArithExpressions
  4. {
  5.  
  6. public static void main(String[] args)
  7. {
  8. int a = 1, b = 3, i = 4, j = 9, k = 6, x = 2, y = 3, r = 2, n = 7, m = -12, rad = 10;
  9. double res, area, areaRound;
  10.  
  11. res = (x+y)/2;
  12. System.out.println("(x+y)/2= "+res);
  13.  
  14. res = Math.pow((1+r)/100.0, n);
  15. //this takes two arguments the base then the exponent,
  16. //the base is first input then exp is second
  17.  
  18. System.out.println("(1+r)/100^7)=" + res);
  19.  
  20. res = Math.sqrt(a*a+b*b);
  21. System.out.println("math.sqrt(a*a+b*b)="+res);
  22.  
  23. area = Math.pow(rad,2)*Math.PI;
  24. System.out.println("Math.pow(rad,2)*Math.PI"+area);
  25.  
  26.  
  27. areaRound = Math.round(area);
  28. System.out.println(area);
  29.  
  30. area = Math.ceil(area);
  31. // ceil rounds up
  32.  
  33. area = Math.floor(area);
  34. // floor rounds down
  35.  
  36. System.out.println(Math.abs(-12));
  37. //abs finds absolute value, turns all num to pos
  38. }
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement