#Problem with the code not running and instead giving me error

1 messages ยท Page 1 of 1 (latest)

compact roostBOT
#

<@&987246399047479336> please have a look, thanks.

compact roostBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.

#

Here is an AI assisted attempt to answer your question ๐Ÿค–. Maybe it helps! In any case, a human is on the way ๐Ÿ‘. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.

#

To help you identify the issue with your Java code, please provide the code for both the helper class and the main class.

tidal sluice
compact roostBOT
tidal sluice
#

Problem with the code not running and instead giving me error

patent herald
# tidal sluice

I think compiler will give you errors, you dont need to run it tho

#

Check those errors, they should be too clear

tidal sluice
#

wdym by that?

#

is there something i have to remove?

patent herald
#

for variables?

#

cause they are not defined inside the class, they are local to functions

#

so, other functions cant access them

tidal sluice
#

this one from the main file

patent herald
#

Are both files in same package?

tidal sluice
tidal sluice
patent herald
#

Never used JGrasp, but if you dont even make a package, like run in VS Code, it will run

#

I can see many problems with Helper file tho

patent herald
tidal sluice
#

idk project explorer

patent herald
tidal sluice
#

can you show me wym

patent herald
tidal sluice
#

like this?

patent herald
tough plume
#

Why are you not using an ide like IntelliJ?

tidal sluice
#

because thats what the majority of ppl use in my school and also professors. and it has a 30 day trial

jagged mist
#

There is a paid version but you won't need that ever

#

Anyways, the issue here is that CoinStarHelper is not compiled

#

You can see CoinStarMain has a .class file, but CoinStarHelper doesn't

tidal sluice
#

yeah i see that since it couldnt run the code

jagged mist
#

Try to compile the CoinStartHelper class first

#

Let's see if that solves it

tidal sluice
#

no it doesnt, it gives me an error where it cannot find symbol

jagged mist
#

Show the error

tidal sluice
jagged mist
#

So.. there is a lot of wrong code in your CoinStarHelper

#

You used a variable named TotalCost but it doesn't exist ( is it a function? because then it needs to be TotalCost()

#

And more

tough plume
#

just scroll down

#

community is completely free

jagged mist
#

the rest of the errors is about that the variables you try to print don't exist
numQ, numD, numN and numP

#

If you fix that and then compile both files again it should work

#

But the next step needs to be to download a proper IDE like IntelliJ

jagged mist
#

It'll make your life alot easier

tidal sluice
patent herald
#

even vs code is much better than that -_-

tough plume
#

but wouldnt recommend vsc for java

jagged mist
#

For example, if you declare them in an if statement, you can't use them outside of the if statement

#
public void myFunction(){ // Scope 1
  int first = 0;
  if (something){ // Scope 2
      int second = 0;
      first = 1; // Works
      second = 1; // Works
  }
  first = 2; // Works
  second = 2; // ERROR, that variable doesn't exist in this scope
}
patent herald
tidal sluice
jagged mist
#

It's up to you to fix it ยฏ_(ใƒ„)_/ยฏ

#

It won't compile like this

jagged mist
tidal sluice
#

but it was before the changes i made

tidal sluice
jagged mist
tidal sluice
#

what is Project JDK is not defined?

olive granite
tidal sluice
#

uhh ive never used this ide b4 so im kinda lost

jagged mist
#

Just google

#

jetbrains has a lot of articles on this stuff

young cedar
compact roostBOT
#

Closed the thread due to inactivity.

If your question was not resolved yet, feel free to just post a message to reopen it, or create a new thread. But try to improve the quality of your question to make it easier to help you ๐Ÿ‘