Advertisement
Guest User

Untitled

a guest
Feb 27th, 2020
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. import kotlin.math.*
  2.  
  3. class Z {
  4. fun SOfRectangle(a : Int, b : Int) : Int { // 1
  5. return a*b
  6. }
  7.  
  8. fun SOfSquare(radius : Double) : Double { // 2
  9. return Math.PI * radius * radius
  10. }
  11.  
  12. fun DifBetween(x1 : Double, x2 : Double, y1 : Double, y2 : Double) : Double { // 3
  13. return sqrt((x1 - x2)*(x1-x2) + (y1 - y2)*(y1-y2))
  14. }
  15.  
  16. fun predChet(num : Int) : Boolean { // 4
  17. if (num % 2 == 0) {
  18. return true
  19. }
  20. return false
  21. }
  22.  
  23. fun predOneOfThree(a : Int, b : Int, c : Int) : Boolean { // 5
  24. if ((a > 0 && b < 0 && c < 0) || (a < 0 && b > 0 && c < 0) || (a < 0 && b < 0 && c > 0)) {
  25. return true
  26. }
  27. return false
  28. }
  29. fun checkFree(a : Int, b : Int, c : Int) : Boolean { // 6
  30. if (a < b && b < c) return true
  31. return false
  32. }
  33.  
  34. fun sin(x : Double) : Double { // 7
  35. if (x >= 5.0) {
  36. return Math.sin(x)
  37. }
  38. else {
  39. return 6.0-x
  40. }
  41. }
  42.  
  43. fun cos(x : Double) : Double { // 8
  44. if (x >= -5) return x*x
  45. else return Math.cos(x)
  46. }
  47.  
  48. fun tan(x : Double) : Double { // 9
  49. if (x <= 0) return Math.tan(x)
  50. else return 1/x
  51. }
  52.  
  53. fun ten(a : Double, b : Double) : Double { // 10
  54. var sum = 0.0
  55. for(i in floor(a).toInt()+1 until ceil(b).toInt()) {
  56. sum += i.toDouble().pow(2.0)
  57. }
  58. return sum
  59. }
  60.  
  61. fun factorial(n: Int): Double { // 11
  62. var result = 1.0
  63. for (i in 1..n) {
  64. result *= i
  65. }
  66. return result
  67. }
  68.  
  69.  
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement