Error message else without if


#1

public class Droid
{

int batteryLevel;

public Droid();

{
batteryLevel=100;
}

public void activate()
{

System.out.println("Activated.How can i help you?");
batteryLevel=(batteryLevel)-5;
System.out.println("Battery level is:" + batteryLevel + "%");

}

public void chargeBattery(int hours);
{
  System.out.println("Droid charging....");
  batteryLevel=batteryLevel+hours;
  if(batteryLevel>=100) 
  batteryLevel=100;
  System.out.println("Battery level is:" + batteryLevel + "%");
  else 
  System.out.println("Battery level is:" + batteryLevel + "%");

}

public void checkBatteryLevel()
{

System.out.println("Battery level is:" +batteryLevel+ "%");
return batteryLevel;
}
public void hover(int feet)
{
if(feet>2)
System.out.println("droid cannot hover above 2 feet");

  else

System.out.println("Hovering...");
batteryLevel=batteryLevel-20;
System.out.println("Battery level is:" +batteryLevel+ "%");

}

public static void main(String[] args)
{
Droid Droid=new Droid();
Droid.activate();
Droid.chargeBattery(5);
Droid.hover(3);
}

}


#2

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.