package com.lovcoding.day04;

import java.util.Random;
import java.util.Scanner;

public class Test05_DoWhile01 {
    public static void main(String[] args) {
        //猜数字
        Random random = new Random();
        int number = random.nextInt(5);
        //限制次数
        int count = 3;
        //输入
        Scanner scanner = new Scanner(System.in);
        //格式
        do {
            System.out.println("请输入1-5");
            int i = scanner.nextInt();
            if ( i == number){
                System.out.println("猜对了");
                break;
            }
            //猜测次数 -1
            count--;
        }while (count > 0);
    }
}
