1. Member
Join Date
Aug 2016
Posts
3
Rep Power
0

## graph

I m real new to java.I want to know how can one create a graph where on x-axis =0,.....,1 and y-axis=0,.......,1000.now i want to know how to create such graph can be produce base on the number step you have enter(even grid).where the user can input the number of step but this steps are in within this interval on x-axis=[0,1],and on y-axis=[0,1000].please guys help!

2. ## Re: graph

How is the graph to be displayed?
Do you want to write the code or do you want to use a package to draw the graph?

What have you tried?

3. Member
Join Date
Aug 2016
Posts
3
Rep Power
0

## Re: graph

I want to write the code and the graph should be like the graph of y=sqrt{x}.

4. Member
Join Date
Aug 2016
Posts
3
Rep Power
0

## Re: graph

i have this code:
/*
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package fuctiongraph;

/**
*
* @author Moody
*/
public class FuctionGraph {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {

// number of line segments to plot
int n = Integer.parseInt(args[0]);

// the function y = sin(4x) + sin(20x), sampled at n+1 points
// between x = 0 and x = pi
double[] x = new double[n+1];
double[] y = new double[n+1];
for (int i = 0; i <= n; i++) {
x[i] = Math.PI * i / n;
y[i] = Math.sin(4*x[i]) + Math.sin(20*x[i]);
}

// rescale the coordinate system
StdDraw.setXscale(0, Math.PI);
StdDraw.setYscale(0.0, 1.0);

// plot the approximation to the function
for (int i = 0; i < n; i++) {
StdDraw.line(x[i], y[i], x[i+1], y[i+1]);
}
}
}

5. ## Re: graph

[code]
[/code]

to get highlighting and preserve formatting.

The code doesn't have its import statements but
It looks like that code uses 3rd party packages and classes that not many people here are familiar with.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•