• February 22nd, 2010, 10:31 AM
simply_stunning79
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:

Code :

```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.
Code :

```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]
• February 22nd, 2010, 06:48 PM
helloworld922