-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathhw1-answer-in-class.kt
More file actions
45 lines (41 loc) · 994 Bytes
/
hw1-answer-in-class.kt
File metadata and controls
45 lines (41 loc) · 994 Bytes
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
40
41
42
43
44
45
fun main() {
// Step 1: Declare Variables
val candles = 2
val layers = 6
println("Number of Candles = $candles") // one single value of variable
//println("Number of Candles = ${candles+layers}") // total of multiple values
println("Length of cake top = $candles")
println("Number of layers = $layers")
// step 1: print candles
printCakeCandles(candles)
// step 2: print cake top
printCakeTop(candles)
// step 3: print cake layers
printCakeBottom(candles, layers)
}
fun printCakeCandles(candles: Int){
print(" ")
repeat(candles){
print(",")
}
println() // Print an empty line
print(" ")
repeat(candles){
print("|")
}
println() // Print an empty line
}
fun printCakeTop(candles: Int) {
repeat(candles + 2) {
print("=")
}
println()
}
fun printCakeBottom(candles: Int, layers: Int){
repeat(layers) {
repeat(candles + 2){
print("@")
}
println()
}
}