Skip to main content

NIC birthday checker Using Scala

package main.scala

import scala.util.control._

/**  * Created by Dinuka on 4/8/2017.  */object Nic extends App{
  print("Please input your NIC :")
  var nicNo = scala.io.StdIn.readLine()

  val year = nicNo.substring(0,2).toInt+1900
  var monthdates=Array(31,29,31,30,31,30,31,31,30,31,30,31)

  var dayNo = nicNo.substring(2,5).toInt

  var gender = "Male"  if (dayNo>500){
    dayNo-=500    gender  = "Female"  }

  def setMonth(day1:Int): String ={
    var month ,da =0    var day=day1
    var i=0
    val loop = new Breaks;

    loop.breakable {
      for(i<- 0 until monthdates.length-1){
        if(day < monthdates(i)){
          month=i+1          da=day
          loop.break
        }else{
          day =day-monthdates(i)
        }
      }
    }

    ("\nMonth : " + month + "\nDate : " + da+"\n");
  }

  println("Year :"+year+setMonth(dayNo)+"\nGende :"+gender)
}
/**Please input your NIC :952640000VYear :1995Month : 9Date : 20
Gende :Male  **/

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