Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

>> REGISTER NOW TO START POSTING

# Thread: Trying to make a physics calculator, where i will calculate the energylevels of an hydrogen atom. Need some help :P

1. ## Trying to make a physics calculator, where i will calculate the energylevels of an hydrogen atom. Need some help :P

Hey!
I just started to learn java, my idea is to make a little utility tool where i can calculate the energylevel of an hydrogen atom. My code is
"
```import java.util.Scanner;

import javax.naming.spi.DirStateFactory.Result;

import static java.lang.Math.PI;

public class energihydrogen {
static double b = 2.18 * pwo(10, -18) ;

static int counter = 0;
public static void main(String[] args) {
{
double a;
double c;

Scanner in = new Scanner(System.in);

System.out.println("write a number between[N=1,2,3,4....]");
a = in.nextInt();
System.out.println("you wrote a number!"+a);

}
}

private static double pwo(int i, int j) {
// TODO Auto-generated method stub
return 0;
}

Double result ;
result c = - b / pwo(double a, 2) ;

public static void herpderp (double output) {
counter++ ;
System.out.println("result " + counter + " is " + output) ;
}
}```
"
i want the user to be able to change the variable "a" so they can calculate the level they want, and i keep getting theese errors. I have probably done someting really wrong.. I would really apreciate som help: D
Thank you

2. ## Re: Trying to make a physics calculator, where i will calculate the energylevels of an hydrogen atom. Need some help :P

I have probably done someting really wrong.
Does the code compile? If not, and you can't understand the compiler's messages, post them.

---

It is usual to start classes with a capital letter: so something like EnergyHydrogen. Also be careful about how you format the code. The closing } should line up with the line containing the opening {. That way it is clear what is nested inside what. (I prefer using spaces rather than tabs to indent because they can be more predictable.)

 Also you have "junk" in the program - an unused herpderp() method, and an unused import of Result. Get rid of these things as they can only obscure whatever the problem is.

3. ## Re: Trying to make a physics calculator, where i will calculate the energylevels of an hydrogen atom. Need some help :P

Originally Posted by pbrockway2
Does the code compile? If not, and you can't understand the compiler's messages, post them.

---

It is usual to start classes with a capital letter: so something like EnergyHydrogen. Also be careful about how you format the code. The closing } should line up with the line containing the opening {. That way it is clear what is nested inside what. (I prefer using spaces rather than tabs to indent because they can be more predictable.)

 Also you have "junk" in the program - an unused herpderp() method, and an unused import of Result. Get rid of these things as they can only obscure whatever the problem is.
Hey, when i try to compile with eclipse it says

"Exception in thread "main" java.lang.Error: Unresolved compilation problem:" and should should i just remove the method like here and the unused result?

at energihydrogen.main(energihydrogen.java:11)"
[code/java]
import java.util.Scanner;

import javax.naming.spi.DirStateFactory.Result;

import static java.lang.Math.PI;

public class energihydrogen {
static double b = 2.18 * pwo(10, -18) ;

static int counter = 0;
public static void main(String[] args) {
{
double a;
double c;

Scanner in = new Scanner(System.in);

System.out.println("write a number between[N=1,2,3,4....]");
a = in.nextInt();
System.out.println("you wrote a number!"+a);

}
}

private static double pwo(int i, int j) {
// TODO Auto-generated method stub
return 0;
}

Double result ;
c = - b / pwo(double a, 2) ;

counter++ ;
System.out.println("result " + counter + " is " + output) ;
}
}

[/code]
Thank you awesome forum btw!

4. ## Re: Trying to make a physics calculator, where i will calculate the energylevels of an hydrogen atom. Need some help :P

You are getting that message when your IDE (NetBeans?) attempts to run the program. But would help you at this point is to see the messages that result when the code is compiled. If the IDE won't cooperate, compile the program from the command line.

Yes, remove everything from the program everything that you haven't put there for some specific reason.