所以这是我的代码,我不能打印出 x?我也可以对这个程序有一些建议吗?我还想将打印输出数据存储为 CSV。每笔交易发生的文件。如果你们提供一些链接,我将不胜感激。package mainimport ( "bufio" "fmt" "os" "strconv")func main() { var coke int64 = 15 var sprite int64 = 15 var fanta int64 = 15 var mirinda int64 = 15 var mineralwater int64 = 8 scanner := bufio.NewScanner(os.Stdin) fmt.Print("Coke anount : ") scanner.Scan() cokeAmount, _ := strconv.ParseInt(scanner.Text(), 10, 64) fmt.Print("Sprite Amount : ") scanner.Scan() spriteAmount, _ := strconv.ParseInt(scanner.Text(), 10, 64) fmt.Print("Fanta Amount : ") scanner.Scan() fantaAmount, _ := strconv.ParseInt(scanner.Text(), 10, 64) fmt.Print("Mirinda Amount : ") scanner.Scan() mirindaAmount, _ := strconv.ParseInt(scanner.Text(), 10, 64) fmt.Print("Mineral water Amount : ") scanner.Scan() miniralWaterAmount, _ := strconv.ParseInt(scanner.Text(), 10, 64) var price int64 = (coke * (cokeAmount)) + (sprite * (spriteAmount)) + (fanta * (fantaAmount)) + (mirinda * (mirindaAmount)) + (mineralwater * (miniralWaterAmount)) fmt.Println("The total cost will be : ", price) fmt.Print("Cash received : ") scanner.Scan() mReceived, _ := strconv.ParseInt(scanner.Text(), 10, 64) var mReturn int64 = mReceived - price fmt.Print("Cash returned : ", mReturn) x = ((cokeAmount),(spriteAmount),(fantaAmount),(mirindaAmount),(miniralWaterAmount)) fmt.Println(x) }
1 回答
泛舟湖上清波郎朗
TA贡献1818条经验 获得超3个赞
第 51 行应为
x := []int64{cokeAmount, spriteAmount, fantaAmount, mirindaAmount, miniralWaterAmount}
- 1 回答
- 0 关注
- 114 浏览
添加回答
举报
0/150
提交
取消