dongqian6484 2017-02-16 17:34
浏览 9
已采纳

语法错误:意外的celsfah,期望(

Hello I have a problem i searched but i didn't find the solution. Can you help me please ?

if choix != 1 && choix != 2 {
  fmt.Println("you don't put a correct number!")
  continueProg=true
} else if choix == 1 {
  celsfah()
  fmt.Println("Celsius")
} else {
  //FahCels()
  fmt.Println("Fahrenheit")
}

I tried several solutions but none worked

The Function Celsfah

func celsfah(fahrenheit) {
celsius := 0
fahrenheit := 0
fmt.Println("Entrer une température en Celsius à convertir en Fahrenheit : ")
fmt.Scanln(&celsius)
fahrenheit = celsius*1.8+32
fmt.Println(&fahrenheit)
}
  • 写回答

1条回答 默认 最新

  • dongxiang5879 2017-02-16 21:12
    关注

    I've simplified your code a bit and fixed some issues to turn it into a running program. The main issues were:

    • parameter into celsfah() unnecessary
    • the final Println() statement was printing the pointer to fahrenheit instead of the value

    `

    package main
    
    import (
      "fmt"
    )
    
    func main() {
      choix := 1
    
      if choix != 1 && choix != 2 { 
        fmt.Println("you didn't put in the correct number!")
      } else if choix == 1 { 
        celsfah()
        fmt.Println("Celsius")
      } else {
        //fahcels()
        fmt.Println("Fahrenheit")
      }
    }
    
    func celsfah() {
      celsius := 0.0 
      fahrenheit := 0.0 
      fmt.Println("Enter a temperature in Celsius to convert to Fahrenheit: ")
      fmt.Scanln(&celsius)
      fahrenheit = celsius*1.8 + 32
      fmt.Println(fahrenheit)
    }
    

    `

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号