⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 guessinggame.txt

📁 java的一经典教程
💻 TXT
字号:
// Program to allow the user to play a guess the number game

import javax.swing.JOptionPane;

public class GuessingGame
{

	public static void guessyguessy()
	{
	 	final int SECRETNUMBER = 75;

		String str = JOptionPane.showInputDialog(
		   "Guess the number?");
		int guess = Integer.parseInt(str);

		while (guess != SECRETNUMBER)
		{
		 	if (guess > SECRETNUMBER)
	 			JOptionPane.showMessageDialog(null,"Too high!");
	 		else // guess must be too low
	 			JOptionPane.showMessageDialog(null,"Too low!");

	 		str = JOptionPane.showInputDialog(null,"Try again");
		 	guess = Integer.parseInt(str);
	 	}

	 	JOptionPane.showMessageDialog(null, "Correct!");
	}


   public static void main(String[] args)
   {
      guessyguessy();

      System.exit(0);
   }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -