import java.util.Random;
public class test {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println(genRandomNum(10));
}
/**
* Éú³ÉËæ¼´ÃÜÂë
* @param pwd_len Éú³ÉµÄÃÜÂëµÄ×ܳ¤¶È
* @return ÃÜÂëµÄ×Ö·û´®
*/
public static String genRandomNum(int pwd_len){
//35ÊÇÒòΪÊý×éÊÇ´Ó0¿ªÊ¼µÄ£¬26¸ö×Öĸ+10¸öÊý×Ö
final int maxNum = 36;
int i; //Éú³ÉµÄËæ»úÊý
int count = 0; //Éú³ÉµÄÃÜÂëµÄ³¤¶È
char[] str = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k',
'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
StringBuffer pwd = new StringBuffer("");
Random r = new Random();
while(count < pwd_len){
//Éú³ÉËæ»úÊý£¬È¡¾ø¶ÔÖµ£¬·ÀÖ¹Éú³É¸ºÊý£¬
i = Math.abs(r.nextInt(maxNum)); //Éú³ÉµÄÊý×î´óΪ36-1
if (i >= 0 && i < str.length) {
pwd.append(str[i]);
count ++;
}
}
return pwd.toString();
}
}
ÒÔÏÂÊǼÆËãÁ½¸öÊýÎó²îÊÇ·ñÔÚ10% £¬Èç¹ûÔÚ10%ÒÔÄÚÊÇÕý³££¬ÆäËûÊDz»Õý³££¬ÓýÏСµÄÊý*10%+ÓýÏСµÄÊý=ÓýÏСµÄÊý*1.1%
double costNum =2;//µç·Ñƽ¾ùÈÕµçÁ¿
double amountNum =3; //µçÁ¿Æ½¾ùÈÕµçÁ¿
if(amountNum ......