1、代码实现
#!/bin/bash
goodName1="钢笔"
goodName2="泡面"
echo "请输入$goodName1的价格?"
read price1
echo "请输入$goodName1的数量?"
read num1
total=$(expr $price1 \* $num1)
echo $total
echo "$goodName1:价格:$price1,数量$num1"
echo "请输入$goodName2的价格?"
read price2
echo "请输入$goodName2的数量?"
read num2
total2=$(expr $price2 \* $num2)
echo "$goodName2:价格:$price2,数量$num2"
echo "购物小票:"
echo "$goodName1,价格:$price1,数量$num1,合计:$total"
echo "$goodName2,价格:$price2,数量$num2,合计:$total2"
sum=$(expr $total + $total2)
echo "最终付款:$sum"
2、效果图