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


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

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

  1. #1
    Junior Member
    Join Date
    Jan 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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. #2
    Super Moderator pbrockway2's Avatar
    Join Date
    Jan 2012
    Posts
    987
    Thanks
    6
    Thanked 206 Times in 182 Posts

    Default 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.)

    [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.

  3. #3
    Junior Member
    Join Date
    Jan 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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 View Post
    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!
    Last edited by zichoz; January 15th, 2013 at 02:08 PM. Reason: messed up

  4. #4
    Super Moderator pbrockway2's Avatar
    Join Date
    Jan 2012
    Posts
    987
    Thanks
    6
    Thanked 206 Times in 182 Posts

    Default 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.

Similar Threads

  1. Spatial Data Infrastructure download service as Atom feed
    By asraf in forum What's Wrong With My Code?
    Replies: 3
    Last Post: December 3rd, 2012, 10:28 AM
  2. May Term project: Physics-based games
    By NcAdams in forum Member Introductions
    Replies: 0
    Last Post: May 22nd, 2012, 02:11 PM
  3. Simple Game Physics & Animation (Air Hockey)
    By Spaces Allowed? in forum AWT / Java Swing
    Replies: 6
    Last Post: November 2nd, 2011, 04:48 AM
  4. Cannot calculate. Please help me....
    By safarina02 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: September 15th, 2011, 01:11 PM
  5. [SOLVED] Physics Program
    By pwngrammer in forum Algorithms & Recursion
    Replies: 36
    Last Post: June 15th, 2009, 08:32 AM