039_嵌套分支


package com.atguigu.chapter04.ifesle
import scala.io.StdIn
object Exercise04 {
def main(args: Array[String]): Unit = {
println("请输入运动员成绩")
val speed = StdIn.readDouble()
if (speed <= 8) {
println("请输入运动员性别")
val gender = StdIn.readChar()
if (gender == '男') {
println("进入男子组")
} else {
println("进入女子组")
}
} else {
println("你被淘汰了....")
}
}
}

package com.atguigu.chapter04.ifesle
import scala.io.StdIn
object Exercise05 {
def main(args: Array[String]): Unit = {
println("输入月份")
val month = StdIn.readInt()
println("输入年龄")
val age = StdIn.readInt()
val tikcet = 60
if (month >= 4 && month <= 10) {
if (age >= 18 && age <= 60) {
println("你的票价是:" + tikcet)
} else if (age < 18) {
println("你的票价是:" + tikcet / 2)
} else {
println("你的票价是:" + tikcet / 3)
}
} else {
if (age >= 18 && age <= 60) {
println("你的票价是:" + 40)
} else {
println("你的票价是:" + 20)
}
}
}
}