SHARE
TWEET

Untitled

a guest Jul 22nd, 2019 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   def numberToAverage(number: Int): Unit = {
  2.     var sum = 0
  3.     if (number > 1) {
  4.  
  5.       for (i <- 1 to number) {
  6.         sum += i
  7.       }
  8.       println(sum)
  9.       val average: Double = sum / (number + 1)
  10.       println(s"Average is $average and the number is $number")
  11.     } else {
  12.       println("Please use a number greater than 1 next time")
  13.     }
  14.   }
  15.  
  16.   println("numberToAverage Function")
  17.   println("======================================================")
  18.   println(numberToAverage(11))
  19.   println()
  20.   println()
  21.   println()
  22.  
  23.   def printEven(limit: Int): Unit = {
  24.     for (i <- 0 to limit) {
  25.       var condition = true
  26. //      println(i.toString)
  27.       for (j <- i.toString.toCharArray) {
  28.         if (j.toInt % 2 == 1) {
  29.           condition = false
  30.         }
  31.  
  32.       }
  33.       if (condition) {
  34.         println(i)
  35.       }
  36.     }
  37.   }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top