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
"
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 ;
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
Re: Trying to make a physics calculator, where i will calculate the energylevels of an hydrogen atom. Need some help :P
Quote:
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.)
[Edit] 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.
Re: Trying to make a physics calculator, where i will calculate the energylevels of an hydrogen atom. Need some help :P
Quote:
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.)
[Edit] 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!
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.