-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfirst.kt
39 lines (33 loc) · 1.54 KB
/
first.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
!Create a birthday message in Kotlin
?Introduction
>In this program you will create a short Kotlin program that prints a birthday message with a cake and a birthday banner.
?Prerequisites
>How to open and edit code in https://developer.android.com/training/kotlinplayground, a browser-based Kotlin programming tool.
>Understand the "Hello world!" program from the Write your first Kotlin program codelab.
>How to use println() to write text to the console of the online Kotlin code editor.
?What you will learn
> How to print more complex text from your program.
> How to do basic math in Kotlin and store the results in variables for later use.
> How to create a function to print the same string several times.
> How to create a loop that prints a text snippet multiple times.
?What you will build
> You will create a short program that you can use to print birthday messages, a text-based picture of a cake, and a banner.
?What you need
> A computer with internet access and a modern web browser, such as the latest version of Chrome.
*Written by Google Developers Training team.
*/
fun main() {
println("Hello, \nworld!")
println("Janshi")
println("") //for a line break
print("\n") //also for a line break
return jhanshi()
}
fun jhanshi() {
//when we use println() it only prints in one line, we do have to use \n.
println("Happy Birthday!")
//when we use print() it continue in the same line. So, we have to use \n to break the line.
print("Jhansi\n")
print("You are 25!")
}