文件名称:Java画1-100个随机整数的柱状图,并显示概率
文件大小:2KB
文件格式:TXT
更新时间:2013-12-11 04:00:10
柱状图
import java.applet.*; import java.awt.*; public class Test1 extends Applet { private int onecnt=0; private int twocnt=0; private int threecnt=0; private int fourcnt=0; private int fivecnt=0; private int sixcnt=0; public void paint(Graphics g) { int a[] = new int[100]; int count[] =new int[7]; for(int i=0;i< 100;i++) { a[i]= (int)(Math.random()*6+1); count[a[i]]++; System.out.print(a[i] + " "); switch(a[i]) { case 1:onecnt++;break; case 2:twocnt++;break; case 3:threecnt++;break; case 4:fourcnt++;break; case 5:fivecnt++;break; case 6:sixcnt++;break; } 。。。。