Not understanding whats wrong


#1



i keep getting error

Droid.java:20: error: illegal start of expression
public int checkBatteryLevel(){
^
Droid.java:20: error: ';' expected
public int checkBatteryLevel(){
^
2 errors

https://www.codecademy.com/en/courses/learn-java/projects/droid?link_content_target=interstitial_project


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 + " percent.");
  }
  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 int checkBatteryLevel(){
      System.out.println("Battery level is " + batteryLevel + "%");
      return batteryLevel;
    }
  }
  public static void main(String[] args){}
}


#2

You're missing a closing curly brace for the method chargeBattery


#3

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