File tree 3 files changed +31
-2
lines changed
3 files changed +31
-2
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ !Create a birthday message in Kotlin
3
+
4
+ ?Introduction
5
+ >In this program you will create a short Kotlin program that prints a birthday message with a cake and a birthday banner.
6
+
7
+ ?Prerequisites
8
+ >How to open and edit code in https://developer.android.com/training/kotlinplayground, a browser-based Kotlin programming tool.
9
+ >Understand the "Hello world!" program from the Write your first Kotlin program codelab.
10
+ >How to use println() to write text to the console of the online Kotlin code editor.
11
+
12
+ ?What you will learn
13
+ > How to print more complex text from your program.
14
+ > How to do basic math in Kotlin and store the results in variables for later use.
15
+ > How to create a function to print the same string several times.
16
+ > How to create a loop that prints a text snippet multiple times.
17
+
18
+ ?What you will build
19
+ > You will create a short program that you can use to print birthday messages, a text-based picture of a cake, and a banner.
20
+
21
+ ?What you need
22
+ > A computer with internet access and a modern web browser, such as the latest version of Chrome.
23
+
24
+ *Written by Google Developers Training team.
25
+ */
1
26
fun main () {
2
27
println (" Hello, \n world!" )
3
28
println (" Janshi" )
Original file line number Diff line number Diff line change 1
1
// !Modify a function to have two arguments
2
+ /*
3
+ Important: A variable declared using the val keyword can only be set once. You cannot change its value later in the program.
4
+ You can declare a changeable variable with the var keyword
5
+ */
2
6
fun main () {
3
7
val border = " `-._,-'"
4
- val timesToRepeat = 4
8
+ var timesToRepeat = 4
5
9
printBorder(border, timesToRepeat)
6
10
println (" Happy Birthday, Jhansi!" )
7
11
printBorder(border, timesToRepeat)
Original file line number Diff line number Diff line change 1
- // In this we used function inside a function, we can return a function or rather use it normally.
1
+ // ! In this we used function inside a function, we can return a function or rather use it normally.
2
2
fun main () {
3
3
println (" Hello, world!\n " )
4
4
birthdayMessage()
You can’t perform that action at this time.
0 commit comments