0

how I can draw this function graph in java with applet:

f(x)=ax^3+bsin(x)

I try this:

import java.applet.Applet;
import java.awt.Graphics;
public class Graph extends Applet
{
    public void paint(Graphics g){
    {
        double a=70;
        double n=450;
        int x;
        int y;
        for (int  i=0; i<n+1;i++) 
        {
            x=(int) ((int) (a*i*i*i)+(n*Math.sin(i)));
            y=(int) ((int) (a*i*i*i)+(n*Math.sin(i)));
            g.drawLine(0,0,x,y);}
        }
    }
}

But I got a line

John
  • 1
  • applets are dead technology – Scary Wombat Jun 07 '17 at 07:48
  • It's for science. – John Jun 07 '17 at 08:14
  • 1) See [Java Plugin support deprecated](http://www.gizmodo.com.au/2016/01/rest-in-hell-java-plug-in/) and [Moving to a Plugin-Free Web](https://blogs.oracle.com/java-platform-group/moving-to-a-plugin-free-web). *"It's for science"* Swing and a desktop application (e.g. based on `JFrame`) can also be used for science. More relevant, they will work in the current day and many more people would be able to assist when there are problems. 2) Why use AWT? See [this answer](http://stackoverflow.com/questions/6255106/java-gui-listeners-without-awt/6255978#6255978) for .. – Andrew Thompson Jun 08 '17 at 08:40
  • .. many good reasons to abandon AWT components in favor of Swing. – Andrew Thompson Jun 08 '17 at 08:40

0 Answers0