Bonjour,
comment on peut dessinet une courbe ou un histogramme avec java
merci
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));
}
}
}
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));
}
}
}
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();
}
}
Combien cela coûte-t-il au total ? Quelles aides apportent l'état et les acteurs du marché pour alléger cette charge non choisie ? Tous les détails sur Commentçamarche.net.