Advertisement
Guest User

Untitled

a guest
Sep 6th, 2014
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.wausoft.core
  2. import scala.util.Try
  3.  
  4. object Program extends App {
  5.     print("Please enter a number of seconds: ")
  6.     val time = Try(Console.readInt) getOrElse 0
  7.     val secondsInHour = 3600
  8.     val secondsInMinute = 60
  9.     val hours = time / secondsInHour
  10.     val minutes = (time % secondsInHour) / secondsInMinute
  11.     val seconds = (time % secondsInHour) % secondsInMinute
  12.     println(s"h: $hours, m: $minutes, s: $seconds")
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement