#Keep getting identifier error

3 messages · Page 1 of 1 (latest)

celest tinsel
#

Trying to create a "batteryCalculator", but keep getting identifer errors, from line 11 to line 15, please help!

public class MyClass {
    public static void main(String args[]) {
    class BatteryCalculator {
   
   int tikTokHours = 2;
   int spotifyHours = 3;
   float messaginghours = 1.5f;
   float instagramHours = 0.5f;
   int rechargeTime = 31;
   int phoneBattery = 100;
   phoneBattery+= -1*(tikTokHours*17);
   phoneBattery+= -1*(spotifyHours*5);
   phoneBattery+= -1*(messaginghours*8);
   phoneBattery+= -1*(instagramHours*12);
    System.out.println("The battery of my phone at the end of the day is " + 
    phoneBattery + "%."); 

    }
    }```
stiff lynxBOT
#

This post has been reserved for your question.

Hey @celest tinsel! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.