Java程序编写 • 【第5章 程序:赌博游戏】

本章节总结

返回作业目录


  • 练习一
  • 赌博游戏

Java程序编写 • 【第5章 程序:赌博游戏】_第1张图片


import java.util.Scanner;
public class day4_03 {
     
	public static void main(String[]args){
     
		int qian=20000;
		int jj=(int)(Math.random()*(20000-0+1));
		int dj=(int)(Math.random()*(100-0+1));
		int mai1=100;
		int mai2=1000;
		int mai3=10000;
		int mai4=50000;
		Scanner a=new Scanner(System.in);
		System.out.println("*全部家当:"+qian+"¥");
		System.out.println("*<彩票>项目:100¥\t\t*一张中奖范围:0-200¥");
		System.out.println("*请输入<1>买1张<彩票>\t*<2>买10张<彩票>\t    *<3>买100张<彩票>:");
		while(qian<5000000&&qian>=10){
     
			while(qian>=100&&qian<50000){
     
				boolean c=a.hasNextInt();
				int A=a.nextInt();
				int b=3373650;
				if(A==1&&c==true){
     
					b=3373651;
				}else if(A==2){
     
					b=3373652;
				}else if(A==3){
     
					b=3373653;
				}
					if(b==3373651){
     
						if(qian>=100){
     
							qian=qian-mai1;
							jj=(int)(Math.random()*(200-0+1));
							System.out.println("*你刮开了彩票...");
							System.out.println("*恭喜你,中了"+jj+"¥");
							qian=jj+qian;
							System.out.println("*全部家当:"+qian+"¥");
								A=0;
								b=3373650;
						}else{
     
							System.out.println("*你看了看你的钱包");
							A=0;
							b=3373650;
						}
					}else if(b==3373652){
     
						if(qian>=1000){
     
							qian=qian-mai2;
							jj=(int)(Math.random()*(2000-0+1));
							System.out.println("*你刮开了彩票...");
							System.out.println("*恭喜你,中了"+jj+"¥");
							qian=jj+qian;
							System.out.println("*全部家当:"+qian+"¥");
								A=0;
								b=3373650;
						}else{
     
							System.out.println("*你看了看你的钱包");
							A=0;
							b=3373650;
						}
					}else if(b==3373653){
     
						if(qian>=10000){
     
							qian=qian-mai3;
							jj=(int)(Math.random()*(20000-0+1));
							System.out.println("*你刮开了彩票...");
							System.out.println("*恭喜你,中了"+jj+"¥");
							qian=jj+qian;
							System.out.println("*全部家当:"+qian+"¥");
								A=0;
								b=3373650;
						}else{
     
							System.out.println("*你看了看你的钱包");
							A=0;
							b=3373650;
						}
					}else{
     
					System.out.println("*请输入数字<1><2><3>");
					}
					if(qian>=50000){
     
						System.out.println("*恭喜你,已积攒50000¥,解锁:<老虎机>");
						System.out.println("*<老虎机>项目:50000¥\t\t*一张中奖范围:0-1000000¥");
						System.out.println("*请输入<4>摇动<老虎机>");
					}
			}
			while(qian>=50000&&qian<5000000){
     
				int A=a.nextInt();
				int b=3373650;
				if(A==1){
     
					b=3373651;
				}else if(A==2){
     
					b=3373652;
				}else if(A==3){
     
					b=3373653;
				}else if(A==4){
     
					b=3373654;
				}
					if(b==3373651){
     
						if(qian>=100){
     
							qian=qian-mai1;
							jj=(int)(Math.random()*(200-0+1));
							System.out.println("*你刮开了彩票...");
							System.out.println("*恭喜你,中了"+jj+"¥");
							qian=jj+qian;
							System.out.println("*全部家当:"+qian+"¥");
								A=0;
								b=3373650;
						}else{
     
							System.out.println("*你看了看你的钱包");
							A=0;
							b=3373650;
						}
					}else if(b==3373652){
     
						if(qian>=1000){
     
							qian=qian-mai2;
							jj=(int)(Math.random()*(2000-0+1));
							System.out.println("*你刮开了彩票...");
							System.out.println("*恭喜你,中了"+jj+"¥");
							qian=jj+qian;
							System.out.println("*全部家当:"+qian+"¥");
								A=0;
								b=3373650;
						}else{
     
							System.out.println("*你看了看你的钱包");
							A=0;
							b=3373650;
						}
					}else if(b==3373653){
     
						if(qian>=10000){
     
							qian=qian-mai3;
							jj=(int)(Math.random()*(20000-0+1));
							System.out.println("*你刮开了彩票...");
							System.out.println("*恭喜你,中了"+jj+"¥");
							qian=jj+qian;
							System.out.println("*全部家当:"+qian+"¥");
								A=0;
								b=3373650;
						}else{
     
							System.out.println("*你看了看你的钱包");
							A=0;
							b=3373650;
						}
					}else if(b==3373654){
     
						dj=(int)(Math.random()*(100-0+1));
						if(dj==100){
     
							qian=qian-mai4;
							System.out.println("*你摇动了老虎机...");
							System.out.println("*恭喜你!!!中了1 0 0 0 0 0 0¥,你妈买菜必超级加倍");
							qian=1000000+qian;
							System.out.println("*全部家当:"+qian+"¥");
							A=0;
							b=3373650;
						}else if(dj==0){
     
							qian=qian-mai4;
							System.out.println("*你摇动了老虎机...");
							System.out.println("*恭喜你,中了5 0 0 0 0 0¥,祝你玩斗地主3456没有7");
							qian=500000+qian;
							System.out.println("*全部家当:"+qian+"¥");
								A=0;
								b=3373650;
						}else{
     
							qian=qian-mai4;
							jj=(int)(Math.random()*(98000-0+1));
							System.out.println("*你摇动了老虎机...");
							System.out.println("*恭喜你,中了"+jj+"¥");
							qian=jj+qian;
							System.out.println("*全部家当:"+qian+"¥");
								A=0;
								b=3373650;
						}
					}else{
     
					System.out.println("*请输入数字<1><2><3><4>");
					}
			}
			if(qian<10){
     
				System.out.println("*你输的只剩条裤衩了");
			}
		}
	}
}

你可能感兴趣的:(Java学习进度,java)