中奖程序
使用Java做了一個中獎程序,程序中已經設置中獎的號碼,根據文本提示會讓你輸入四個數字,當你輸入你的四個數字之后程序會給出你是否中獎的結果顯示。
結果演示
代碼演示
package com.ten; import java.util.Scanner; public class ZhongJiang {public static void main(String[] args) {Scanner scan = new Scanner(System.in);System.out.println("請輸入四個數:");int num1 = scan.nextInt();int num2 = scan.nextInt();int num3= scan.nextInt();int num4 = scan.nextInt();if((num1 != 8)&&(num2 != 8)&&(num3 != 8)&&(num4 != 8)&&(num1+num2+num3+num4)%8 != 0){System.out.println("恭喜你中獎了!");}else{System.out.println("很遺憾,再嘗試一下吧!");}}}總結
- 上一篇: docker build -t_在Doc
- 下一篇: linux下软件包清理,Linux运维知