当用户未输入与先前输入的号码相同的号码时,创建将连续接受号码的节目

时间:2017-12-20 10:54:12

标签: java loops

这是我唯一无法创建的程序。请帮帮我。

public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    int i = 0, j=0;
     do {
         System.out.print("Enter number: ");
         i = input.nextInt();

         i=j;
     }

     while (i == j);
     System.out.println("You have inputted the same number on the previous.");

}

1 个答案:

答案 0 :(得分:0)

干杯m8,祝你考试好运:D

  public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int i = 0, j = 999999, input = 0;
         do {
             i = j;
             System.out.print("Enter number: ");
             input = input.nextInt();

             j=input;
         } while (i != j);
         System.out.println("You have inputted the same number on the previous.");

    }