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: 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

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

    import java.io.*;
    import javagently.*;
    class diy130
    {
    public static void main (String [] args) throws IOException
    {
    /* This java program plots the function y = 3 + x^2 from
    x = 0 to x = 10 with delta x = 0.01. */
    Graph y = new Graph("y = 3 + x^2", "x", "y");
    double x;
    y.setSymbol(true); y.setColor(y.red);
    y.setTitle("y = 3 + x^2");
    for (int i = 0; i <= 100; i++ )
    {
    x = i/10.0;
    y.add(x, 3+Math.pow(x,2));
    }
    y.showGraph();
    System.out.println("CTRL-C to end the program.");
    }
    }
    Examine carefully the above program and make sure you understand every java statement. Now change the function to some other functions and plot the corresponding curves.
    import java.io.*;
    import javagently.*;
    class diy131
    {
    public static void main (String [] args) throws IOException
    {
    /* This java program plots the function y = 3 + x^2 from
    x = 0 to x = 10 with delta x = 0.01. */
    Graph y = new Graph("y = 3 + x^2", "x", "y");
    double[] x;
    double[] fx;
    x = new double [101];
    fx = new double [101]; // We need 101 data boxes to hold the data below.
    y.setSymbol(true); y.setColor(y.red);
    y.setTitle("y = 3 + x^2");
    for (int i = 0; i <= 100; i++ )
    {
    x[i] = i/10.0;
    fx[i] = 3+Math.pow(x[i],2);
    y.add(x[i], fx[i]);
    }
    y.showGraph();
    System.out.println("CTRL-C to end the program.");
    }
    }
    The data kept in x[i] and fx[i] may be used at a later stage of the program. Now add in java statements to the above program to print the data x[i] and fx[i] as two columns of numbers each allow four decimal places and a space between the data. Store the resulting program as diy132.java[/SIZE]
    Last edited by helloworld922; February 22nd, 2010 at 06:43 PM.


  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

    Graph isn't a standard Java SE class, do you have the code for that? Without it, there's no way for us to tell where the problem is.

    Also, what is the problem that you are getting?

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. Towards java programming...
    By emigrant in forum Member Introductions
    Replies: 1
    Last Post: February 15th, 2010, 02:17 AM
  3. Please help me with this Java programming
    By simply_stunning79 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: January 14th, 2010, 05:42 AM
  4. Java Programming For Kids
    By JavaPF in forum The Cafe
    Replies: 7
    Last Post: December 7th, 2009, 03:37 PM
  5. Hello java programming forums
    By DnB in forum Member Introductions
    Replies: 2
    Last Post: February 9th, 2009, 06:38 AM