/** * 模仿抛硬币游戏 * @author wangyj1992 * */
public class text1{
   
	public int m = 0;	//统计正面次数
	public int n = 0;	//统计反面次数

	/** * 抛硬币 */
	public void playCoin(){
   
		for(int i=0; i<1001; i++){
   
			double result = Math.random();	//某次抛硬币的结果[0,1)
			if(result>=0.5){
   
				m++;
			}else{
   
				n++;
			}
		}
		System.out.println("正面:"+m);
		System.out.println("反面:"+n);
	}
	public static void main(String[] args) {
   
		text1 game = new text1();
		game.playCoin();
	}
}