• 基于Java写的猜数字

    import java.awt.*; import javax.swing.JOptionPane; public class guessNumber { public static void main(String args[]) { int guesscount=-1;//用户猜的次数 int count=0;//用户猜的数字 int number=(int)(Math.random()*100);//0-100的随机数 while(number!=count) { count=Integer.parseInt(JOptionPane.showInputDialog("guess a number between 0 amd 100")); if(number>count) { JOptionPane.showMessageDialog(null, "too low"); } if(number<count) { JOptionPane.showMessageDialog(null, "too high"); } guesscount++; } JOptionPane.showMessageDialog(null, "you guessed the number -"+count+"-in"+guesscount+"guess !!!"); } }

    0
    470
    836B
    2019-03-27
    32
上传资源赚积分or赚钱