【Java】摸彩 → Random
後面一樣用布林Boolean下去做判斷,有嘗試用函式Function下去寫,不過失敗了!其random部分老師上課有讓我們抄原始碼sourse sode...阿翔就只把之前那猜拳的程式中間猜拳的部份換為random罷了!! import java.io.*; public class ex_random{ public static void main(String[]args) throws IOException{ boolean flag=true; String str; BufferedReader buf_YesNo; buf_YesNo=new BufferedReader(new InputStreamReader(System.in)); System.out.println("摸彩摸彩..祝你中頭彩!"); do{ int i,intTransform; double doubleAR; System.out.println(); for(i=1;i<11;i++){ doubleAR = Math.random(); intTransform = (int)(doubleAR*100); System.out.println("第\t"+i+"\t次為 "+intTransform); } System.out.println(); char charYesNo; System.out.print("輸入Y繼續,N離開 → ");