kotlin 分割字符_Kotlin程序检查字符是元音还是辅音
·
kotlin 分割字符
Given a character, we have to check whether it is vowel or consonant.
给定一个字符,我们必须检查它是元音还是辅音。
Example:
例:
Input:
ch = 'A'
Output:
'A' is a vowel.
Input:
ch = 'H'
Output:
'H' is a consonant.
检查Kotlin中字符是元音还是辅音的程序 (Program to check whether a character is vowel or consonant in Kotlin)
package com.includehelp.basic
import java.util.*
//Main Function, entry Point of Program
fun main(args: Array<String>) {
// InputStream to get Input
val scanner = Scanner(System.`in`)
//Input Character
print("Enter Character : ")
val c = scanner.next()[0]
when (c) {
'a','e' ,'i' ,'o' ,'u','A','E','I','O','U' -> println("The given character $c is vowel")
else -> println("The given character $c is consonant")
}
}
Output
输出量
Run 1:
Enter Character : d
The given character d is consonant
---
Run 2:
Enter Character : A
The given character A is vowel
---
Run 3:
Enter Character : u
The given character u is vowel
翻译自: https://www.includehelp.com/kotlin/check-whether-a-character-is-vowel-or-consonant.aspx
kotlin 分割字符
更多推荐


所有评论(0)