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 2 of 2

Thread: Thought I had this figured out and then.....

  1. #1
    Junior Member
    Join Date
    Jul 2013
    Posts
    4
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Thought I had this figured out and then.....

    I keep getting this error: PowerJDialog.java:28: error: cannot find symbol
    if (p.Power(pow))
    ^
    symbol: method Power(int)
    location: variable p of type Power
    1 error

    Tool completed with exit code 1

    I have no idea what it means or how to fix it. In my Java book it has no solution to this error, here is my code:

    import javax.swing.JOptionPane;
     
    //Louis Friedmann
    //July 16, 2013
    //This proragm asks for the number and expontant and outputs the result
     
    public class PowerJDialog
    {
     
    	 public static void main(String[] args) {
     
    					 //Variables Declaration
    		 	   		 String inputString; //input
    		 	         int a;  //base number
    		 	         int n; // exponant number
    		 	         int pow; //power
    	         		 String powerResult; // give the reuslt as math
     
    	         		 //Input
    					 inputString = JOptionPane.showInputDialog("Please enter a number");
    					 a = Integer.parseInt(inputString);
     
    					 inputString = JOptionPane.showInputDialog("Please enter a multiplier?");
    					 n = Integer.parseInt(inputString);
     
    					 //Calculation
    					 Power p= new Power(a,n); //create new object
    					 	if (p.Power(pow))
    					 	  {
    					 	    powerResult =  a + " power " + n + " is " + Math.pow(a,n);
    					 	  }
     
    					 //Output
     
    	         		JOptionPane.showMessageDialog(null, powerResult);
     
    	         		 //exits the program
    						         System.exit(0);
    	}
     
     
    }

    Any ideas of what could be going wrong?


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Thought I had this figured out and then.....

    Method names, like Power(), do not usually begin with a capital letter or have the same name as the class unless a constructor. Some resist the use of Java's naming conventions or wonder at the value of using them, but this is one of those occasions when it's clear to guess the source of an error simply because of a naming convention violation.

    Hope this helps. Good luck!

Similar Threads

  1. Replies: 3
    Last Post: March 9th, 2013, 07:22 PM
  2. thought i had it, then i sneezed and lost it (randomly generated numbers)
    By fakeClassy in forum Java Theory & Questions
    Replies: 13
    Last Post: July 17th, 2011, 04:16 PM
  3. Code working, but not the way I thought...
    By JLogan3o13 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: December 28th, 2010, 01:34 PM
  4. [SOLVED] I thought that this would be right?
    By jwb4291 in forum What's Wrong With My Code?
    Replies: 7
    Last Post: June 29th, 2010, 03:26 PM