小白学java的第七天!
JAVA流程控制语句
会员抽奖系统
import java.util.Scanner; public class work{ public static void main(String[] args){ int num = (int)(Math.random()*10); Scanner sc = new Scanner(System.in); System.out.println(“欢迎登陆腾讯互联抽奖系统”); System.out.println(“请输入4位会员号码:”); String number = sc.nextLine(); int intnum = Integer.parseInt(number); int baiwei = intnum/100%10; if(num == baiwei){ System.out.println(“恭喜中奖”); }else{ System.out.println(number +"," + “谢谢支持”); } } }
搬桌子问题
int age = (int)(Math.random() * 10); char sex = ‘男’; if ((age > 7) || (age > 5 && sex == ‘男’)){System.out.println(“可以搬动桌子”); }else { System.out.println(“搬不了桌子,你还很小”);}
|