| 发表于:2007-08-15 00:50:592楼 得分:0 |
import java.text.decimalformat; import javax.swing.joptionpane; class oopp{ private void getrandom(int sel ,int min,int max){ int i,j; double num,num1; double temp,temp1; decimalformat df =new decimalformat( "00 ");//数字格式化不足两位前面加0 h_show_header(); for(j=1;j <=sel;j++){ system.out.print( "第 "+ j + "注: "+ "\t "); for (i=0;i <7;i++){//一共产生7位随机数 //temp获取前6位数的值,temp1获取最后一位的值 temp=math.random() * (max-min+1); temp1=math.random() * (16-1+1); //num=floor(temp),num1=floor(temp1) num=math.floor(temp)+min; num1=math.floor(temp1)+min; if(i==6){//打印到第6位加*号再打印第7位 system.out.print( "* " + df.format(num1) + " "); } else{ system.out.print( " "+df.format(num) + " "); } } system.out.println( "\n "); } h_money(sel); } public static void main(string[] args){ int selnum; string tempstr; oopp jop = new oopp(); tempstr=joptionpane.showinputdialog(null, "请输入要买几注? "); selnum=integer.parseint(tempstr); jop.getrandom(selnum,1,23); } private void h_money(int money){//foot system.out.println( "-------------------------------------------------- "); system.out.println( "\t\t "+ "多谢惠顾,总共购买: "+money+ "注 "); system.out.println( "\t\t "+ "您一共花费了: "+ money*2 + "元 "); system.out.println( "-------------------------------------------------- "); } private void h_show_header(){//head system.out.println( "-------------------------------------------------- "); system.out.println( "/////////////欢迎使用双色球自动选号系统/////////// "); system.out.println( "-------------------------------------------------- "); } } | | |
|