import java.applet.Applet;
import java.awt.Graphics;
import javax.swing.*;
public class rata extends Applet {
double rat;
public void init() {
String n,m;
double n1,n2,b=0;
n = JOptionPane.showInputDialog("banyak data ");
n1=Double.parseDouble(n);
for (int i=0;i<n1;i++){
m = JOptionPane.showInputDialog("masukkan bilangan");
n2=Double.parseDouble(m);
b=b+n2;
}
rat=b/n1;}
public void paint(Graphics g)
{
g.drawString("rata"+rat,25,25);
}
}
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar