语法错误:意外的逗号,期待 g

所以这是我的代码,我不能打印出 x?我也可以对这个程序有一些建议吗?我还想将打印输出数据存储为 CSV。每笔交易发生的文件。如果你们提供一些链接,我将不胜感激。


package main


import (

    "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)

    


}



PIPIONE
浏览 115回答 1
1回答

泛舟湖上清波郎朗

第 51 行应为x := []int64{cokeAmount, spriteAmount, fantaAmount, mirindaAmount, miniralWaterAmount}
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Go