//定义文具信息为元组类型
var wenju = ("铅笔","橡皮","录音笔","书包","书本")
//定义铅笔的数量为整数类型
var qbNum:Int
qbNum = 10
//定义橡皮的数量为整数类型
var xpNum:Int
xpNum = 10
//定义录音笔的价格为浮点数量
var lybPrice:Double
lybPrice = 3.14
//定义书包的数量为整数类型
var bagNum:Int
bagNum = 10
//定义书本的数量为整数类型
var bookNum:Int
bookNum = 10
/*
(1) 使用for循环打印元组的内容循环5次以上(10分)✔️
(2) 编写switch控制语句,判断当case shopingName == “铅笔” 时打印“num=100”(10分)✔️
(3) 编写if shopingName == “橡皮” 时,打印“num = 200”(10分)✔️
(4) 编写if shopingName == “ 录音笔” 时,打印“pice = 125.5” else 打印“pice = 128.5”(10分)✔️
*/
//使用for循环打印元组的内容循环5次以上
for i in 1...6 {
print(wenju)
}
//编写switch控制语句,判断当case shopingName == “铅笔” 时打印“num=100”
var shopingName = "铅笔"
switch shopingName {
case "铅笔":
print("num=100")
default:
print("notFound")
}
shopingName = "橡皮"
//编写if shopingName == “橡皮” 时,打印“num = 200”
if shopingName == "橡皮" {
print("num = 200")
}
shopingName = "录音笔"
//编写if shopingName == “ 录音笔” 时,打印“pice = 125.5” else 打印“pice = 128.5”
if shopingName == "录音笔" {
print("price = 125.5")
} else {
print("price = 128.5")
}
/*
(1) 把元组的内容转换为字符串(10分)✔️
(2) 把转换后的字符串打印出来(10分)✔️
*/
//把元组的内容转换为字符串
let string = wenju
//把转换后的字符串打印出来
print(string)