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: Java cant find symbols?

  1. #1
    Junior Member
    Join Date
    Sep 2012
    Posts
    10
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Java cant find symbols?

    Here is the code that is giving me problems. im trying to write code that will find the distence between two points. but i get the cannot find symbol error on lines 27-29(when i start doing math).

    import java.lang.*;
    import java.util.Scanner;
     
    public class Program
    {
    	public static void main (String[] args)
    	{
      	double x1, y1, x2, y2; // coordinates of two points
      	double distance;   	// distance between the points
     
      	Scanner scan = new Scanner(System.in);
     
      	// Read in the two points
      	System.out.print ("Enter the coordinates of the first point " +
               	"(put a space between them): ");
      	x1 = scan.nextDouble();
      	y1 = scan.nextDouble();
     
      	System.out.print ("Enter the coordinates of the second point: ");
      	x2 = scan.nextDouble();
      	y2 = scan.nextDouble();
     
      	// Compute the distance
     double a, b, c, d, e, f;
            a = x2 + x1;
            b = y2 + y1;
            e = Math.java.pow(a,2);
            f = Math.java.pow(b,2);
            distance = Math.java.sqrt((e + f));
     
      	// Print out the answer
      	System.out.println(distance);
    	}
    }
    Last edited by jjd712; September 19th, 2012 at 10:25 PM.


  2. #2
    Junior Member
    Join Date
    Sep 2012
    Posts
    26
    My Mood
    Bored
    Thanks
    6
    Thanked 5 Times in 4 Posts

    Default Re: Java cant find symbols?

    Well, when you call the Math.java.pow you don't actually need to add the .java in there, that's why it's giving you the cannot find symbol error, afterwards you're going to run into initialization errors, when you compute the distance, you're program is going to try to compute d as
    Math.sqrt((e+f));
    however, e and f have not yet been initialized!

  3. The Following User Says Thank You to ChicoTheMan94 For This Useful Post:

    jjd712 (September 19th, 2012)

  4. #3
    Junior Member
    Join Date
    Sep 2012
    Posts
    10
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Java cant find symbols?

    yeah i caught myself with e and f. that is fixed now. removing the.java worked and the code ran without errors. Thanks a bunch!

  5. #4
    Junior Member
    Join Date
    Sep 2012
    Posts
    26
    My Mood
    Bored
    Thanks
    6
    Thanked 5 Times in 4 Posts

    Default Re: Java cant find symbols?

    Quote Originally Posted by jjd712 View Post
    yeah i caught myself with e and f. that is fixed now. removing the.java worked and the code ran without errors. Thanks a bunch!
    Awesome, glad it worked. Nice catch with the e and f. Good Luck!

Similar Threads

  1. Use a Method in Java to find the Last name of any given name
    By finjws in forum Collections and Generics
    Replies: 5
    Last Post: February 20th, 2012, 04:33 AM
  2. Where are all the symbols!? Poor Java can't find them... :(
    By coffecupcake in forum What's Wrong With My Code?
    Replies: 4
    Last Post: January 17th, 2012, 03:08 PM
  3. how to find stack size in java
    By aditiya in forum Java Theory & Questions
    Replies: 6
    Last Post: July 8th, 2011, 06:29 AM
  4. Replies: 7
    Last Post: November 23rd, 2010, 11:03 PM
  5. [SOLVED] How to a set java class path?
    By captjade in forum Java Theory & Questions
    Replies: 1
    Last Post: March 10th, 2009, 06:40 AM