kotlin 判断数字
Given a number N, we have to check whether it is EVEN or ODD.
给定数字N ,我们必须检查它是偶数还是奇数 。
Example:
例:
Input:
N = 13
Output:
"ODD"
Input:
N = 24
Output:
"EVEN"
程序在Kotlin检查偶数或奇数 (Program to check EVEN or ODD in Kotlin)
/*
* Kotlin program to Input Integer
* Numbers and check Number is Even or ODD
*/
package com.includehelp.basic
import java.util.*
// Main Method Entry Point of Program
fun main(args: Array<String>) {
// InputStream to get Input
val reader = Scanner(System.`in`)
//Input Integer Value
println("Enter Integer Value : ")
var number = reader.nextInt();
val str = if(number%2==0) "EVEN" else "ODD"
println("Number is $str")
}
Output
输出量
RUN 1:
Enter Integer Value :
34
Number is EVEN
---
Run 2:
Enter Integer Value :
15
Number is ODD
翻译自: https://www.includehelp.com/kotlin/check-whether-a-number-is-even-or-odd.aspx
kotlin 判断数字