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

Thread: Please help me with this Java programming

  1. #1
    Junior Member
    Join Date
    Jan 2010
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post Please help me with this Java programming

    Hello everyone I am a BSC Mathematics student and very beginner in Java Programming and as part of my Mathematics degree I am also learning Algorithm with Java programming. I am in very early stages of Java so I could be making very silly mistake but believe it or not but I am stuck with this error for last 2 days but still cannot figure out where is the problem. Anyone please help me I will really appreciate that.

    Following is the programme code I am using:
    class diy70
    	{
    		public static void main(String[] args)
    		{
    			int degree;
    			degree = 0;
     
    			double px, x;
    			/* px is the variable used to store the result of the polynomial at x.
    			*/
    		    Calculate Taylor_Polynomials tp=newCalculate_Taylor_Polynomials();
    			// Evaluate the polynomial at x = 0.2.
    			x = 0.2;
    			switch (degree) {
    				case 0: px = tp.p0(x); tp.printpx(0.8, x, px); break;
    				case 1: px = tp.p1(x); tp.printpx(0.8, x, px); break;
    				case 2: px = tp.p2(x); tp.printpx(0.8, x, px); break;
    				default: System.out.println("nothing is done.");
    				}
    	}
    	static class Calculate_Taylor_Polynomials
    	{
    		/* Return the result of the polynomial in P.3 Lecture 2 */
    		double p0(double x)
    		{
    			double pofx =1.0;
    			return pofx;
    		}
    		Double p1 (double x)
    		{
    			double pofx = 1.0 + x;
    			return pofx;
    		}
    		double p2(double x)
    		{
    			double px = 1.0 + x + Math.pow(x,2);
    			return px;
    		}
    		void printpx(int degree, double x, double px)
    	   {
    			System.out.println("Degree " + degree + "polynomial");
    			System.out.println ("P( = " + x + ")=" + px);
    			}
    	 }
    }
    But when I run the above programme I am getting error on line 11 saying something like this:

    ';' expected and also there is ^ this sign between Polynomials and tp


    Will wait for reply and may God bless you for this.
    Last edited by helloworld922; January 13th, 2010 at 06:43 PM. Reason: Please use [code] tags!


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Please help me with this Java programming

    Calculate Taylor_Polynomials tp=newCalculate_Taylor_Polynomials();
    It looks like you're missing a space between "new" and "Calculate_Taylor_Polynomials();"
    Calculate Taylor_Polynomials tp=new Calculate_Taylor_Polynomials(); // fixed

  3. #3
    Senile Half-Wit Freaky Chris's Avatar
    Join Date
    Mar 2009
    Posts
    834
    My Mood
    Cynical
    Thanks
    7
    Thanked 105 Times in 90 Posts

    Default Re: Please help me with this Java programming

    Also an underscore

    Calculate Taylor_Polynomials tp=newCalculate_Taylor_Polynomials();
    Calculate_Taylor_Polynomials tp=new Calculate_Taylor_Polynomials();

  4. #4
    Junior Member
    Join Date
    Jan 2010
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Please help me with this Java programming

    Thanks , I tried this but the problems is still there . Giving me the same error

  5. #5
    Junior Member
    Join Date
    Jan 2010
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Please help me with this Java programming

    Thanks Chris u were right i forgot to put underscore.

  6. #6
    Junior Member
    Join Date
    Jan 2010
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Please help me with this Java programming

    Also Thanks for your help HelloWorld 922 . I have some more problems so i will put on this tread.

Similar Threads

  1. Required good java programmer
    By manasbeckham in forum Paid Java Projects
    Replies: 5
    Last Post: November 5th, 2010, 08:34 AM
  2. Java Programming For Kids
    By JavaPF in forum The Cafe
    Replies: 7
    Last Post: December 7th, 2009, 04:37 PM
  3. Replies: 5
    Last Post: September 6th, 2009, 04:39 AM
  4. Starting a java programming career
    By oss_2008 in forum The Cafe
    Replies: 3
    Last Post: July 8th, 2009, 07:45 AM
  5. Hello java programming forums
    By DnB in forum Member Introductions
    Replies: 2
    Last Post: February 9th, 2009, 07:38 AM