joptionpane内部while循环

bmp9r5qi  于 2021-06-29  发布在  Java
关注(0)|答案(0)|浏览(228)

即使我认为在while循环中正确使用了joptionpane,我的弹出消息也没有显示。请帮忙。代码是java btw

import java.util.*;

import javax.swing.JOptionPane;
public class Plotpjestueshmeria {
public static void main(String[]args){

    Scanner in= new Scanner(System.in); 
        int p;
        int x;
        int z;

        System.out.print("Type a number:");
        x=in.nextInt();
        System.out.println("Numbers which " + x + " is divisible by, are:");

        for(p=1; p<=x;++p)
            {
            if(x%p==0)
                System.out.println(p);
            }

        System.out.print("Type a number you want to check:");
            z=in.nextInt();
            while(x%z==0)
            {

                int answer=JOptionPane.showConfirmDialog(null, "Do you want to pick another number?");
                System.out.println("Your number IS on the list!");
                        if(answer==0)
                        {
                            System.out.println("Pick another number:");
                            z=in.nextInt(); 
                        }

                        else if(answer==1 )
                            JOptionPane.showMessageDialog(null,"Have a great day! :)" );
                        else if(answer==2)
                            System.exit(0);

            } 
            JOptionPane.showMessageDialog(null,"Your number is NOT on the list! \n Pick another number." );

            z=in.nextInt();
            {
            while(x%z==0)

                System.out.println("Your number IS on the list!");
                int answer=JOptionPane.showConfirmDialog(null, "Your number IS on the list! \n Do you want to pick another number?");

                        if(answer==0)
                        {
                            System.out.println("Pick another number:");
                            z=in.nextInt(); 
                        }

                        else if(answer==1 )
                            JOptionPane.showMessageDialog(null,"Have a great day! :)" );
                        else if(answer==2)
                            System.exit(0);

            }   

        JOptionPane.showMessageDialog(null,"Your number is NOT on the list! \n Have a great day! :)"); 
                System.exit(0);

    }

}

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题