Skip to main content

Find area of Shapes using Scala

def areaOfShapes(): Unit ={
  var choice:Int=0  var r:Int=0  var l:Int=0  var w:Int=0  var b:Int=0  var h:Int=0
  var area:Float=0
  println("Input 1 for to Calculate Area of Circle")
  println("Input 2 for to Calculate Area of Rectangle")
  println("Input 3 for to Calculate Area of Triangle")
  print("Please Input Your Number :")
  choice=scala.io.StdIn.readInt()

  choice match {
    case 1 =>
      print("Input radious of circle :")
      r=scala.io.StdIn.readInt()
      area=(3.14*r*r).toFloat

    case 2 =>
      print("Input length of rectangle :")
      l=scala.io.StdIn.readInt()
      print("\nInput width of rectangle :")
      w=scala.io.StdIn.readInt()
      area=(l*w).toFloat

    case default =>
      print("Input base of triangle :")
      b=scala.io.StdIn.readInt()
      print("\nInput height of triangle :")
      h=scala.io.StdIn.readInt()
      area=(0.5*b*h).toFloat
  }

  println("The area is :"+area)

}

areaOfShapes()

Comments

Popular posts from this blog

Ubuntu 18.04 LTS (bionic beaver)

Hey! Ubuntu lovers  😊  your next buddy,  Ubuntu 18.04 LTS ( bionic beaver )  will release on next 26th of April 2018. There are many new features in this Ubundu 18.04.Okay... Let's see some new features in Ubuntu 18.04 LTS .   New Ubuntu 18.04 has GNOME 3.28   It has a better boot speed. It has a new minimal installation option. Using PPA in new Ubuntu 18.04 is slightly easy. New look in file manager. New installer for Ubuntu 18.04 Server edition. Native support for color emojes. The proposed brand new themes and icon developed by the community will no longer be the default. Default new applications. Some of the are, Video player/Music Player         VLC IDE                                             Visual Studio Code Video Editor                   ...
https://github.com/dinuka-kasun-medis

Koobiyo with Ants