错误:'('标记之前的预期标识符

时间:2015-10-09 20:24:39

标签: arduino token

在if语句中,它不断给我错误:

  

'''令牌

之前的预期标识符

我正在努力工作。

void setup() 
{
  Serial.begin(9600);
  Serial.println("We will be calculating whether or not ");
  Serial.println("you are underweight, normal, overweight, or obese. ");
}

void loop()
{
  float weight;
  float height;
  float BMI = (703 * weight) / (height * height);

  Serial.println("Please input your weight (pounds)");
  while (Serial.available() <= 0);
  weight = Serial.parseInt();
  Serial.println("Please input your height (inches)");
  while (Serial.available() <= 0);
  height = Serial.parseInt();

  if ( BMI < 18.5 )
  {
    Serial.println("Your body mass index is:");
    Serial.println(BMI);
    Serial.println("please wait while I calculate your weight status");
    Serial.println("...");
    delay(500);
    Serial.println("You are underweight, please go eat.");
  }
  if ( BMI >= 18.5 ) && (BMI <= 24.9)
  {
    Serial.println("Your body mass index is:");
    Serial.println(BMI);
    Serial.println("please wait while I calculate your weight status");
    Serial.println("...");
    delay(500);
    Serial.println("Congratulations! You are a normal");
    Serial.println("... kind of.");
  }
  if (BMI >= 25.0) && (BMI <= 29.9)
  {
    Serial.println("Your body mass index is:");
    Serial.println(BMI);
    Serial.println("please wait while I calculate your weight status");
    Serial.println("...");
    delay(500);
    Serial.println("You are Overweight");
    Serial.println("I suggest a jog");
  }
  if ( BMI >= 30.0)
  {
    Serial.println("Your body mass index is:");
    Serial.println(BMI);
    Serial.println("please wait while I calculate your weight status");
    Serial.println("...");
    delay(500);
    Serial.println("You are OBESE.");
    Serial.println("You have no hope.);
   }
}

1 个答案:

答案 0 :(得分:3)

这应该很容易修复。 如果你改变这些行,你的问题应该很容易解决:

if ( BMI >= 18.5 ) && (BMI <= 24.9) 

到正确的形式是

if (( BMI >= 18.5 ) && (BMI <= 24.9))

你的if语句应该只有一对()围绕它的条件:)

相关问题