Anonymous user
Find the last Sunday of each month: Difference between revisions
Find the last Sunday of each month (view source)
Revision as of 23:17, 17 January 2017
, 7 years ago→{{header|Kotlin}}
m (→JS ES6: Reformatted function) |
|||
Line 2,016:
<lang scala>// version 1.0.6
import java.util.
fun main(args: Array<String>) {
print("Enter a year : ")
val year = readLine()!!.toInt()
println("The last Sundays of each month in $year are as follows:")
val calendar = GregorianCalendar(year, 0, 31)
▲ for (month in 1..12) {
▲ daysInMonth = calendar.getActualMaximum(Calendar.DAY_OF_MONTH)
▲ lastSunday = daysInMonth - (calendar[Calendar.DAY_OF_WEEK] - Calendar.SUNDAY)
println("$year-" + "%02d-".format(month) + "%02d".format(lastSunday))
if (month < 12) {
|