|
|
|
|
Bonjour,
import java.applet.Applet;
import java.awt.Graphics;
public class Courbe extends Applet {
//La formule de ta courbe :
double f(double x) {
return (Math.cos(x / 5) + Math.sin(x / 7) + 2) * getSize().height / 4;
}
public void paint(Graphics g) {
for (int x = 0; x < getSize().width; x++) {
g.drawLine(x, (int) f(x), x + 1, (int) f(x + 1));
}
}
}
histogramme :
import java.applet.Applet;
import java.awt.Graphics;
public class Histogramme extends Applet {
//La formule de ton histogramme :
double f(double x) {
return (Math.cos(x / 5) + Math.sin(x / 7) + 2) * getSize().height / 4;
}
public void paint(Graphics g) {
for (int x = 0; x < getSize().width; x+=20) {
g.drawLine(x, getSize().width, x, (int) f(x + 1));
}
}
}
ET tu améliore les graphismes si tu veut... |
Mais tu sais programmer ou pas ?
import java.awt.Graphics;
import javax.swing.JFrame;
public class Histogramme extends JFrame {
public Histogramme() {
setSize(200, 200);
setVisible(true);
}
// La formule de ton histogramme :
double f(double x) {
return (Math.cos(x / 5) + Math.sin(x / 7) + 2) * getSize().height / 4;
}
public void paint(Graphics g) {
for (int x = 0; x < getSize().width; x += 20) {
g.drawLine(x, getSize().width, x, (int) f(x + 1));
}
}
public static void main(String[] args) {
new Histogramme();
}
}
Mais je te conseil d'aprendre le java au lieu de demander sur des forum .. Tiens : ftp://ftp-developpez.com/java/livres/javaEnfants/JavaEnfants.pdf C'est un très bon cours de java |