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

📄 evenodd.java

📁 Java 程序设计教程(第五版)EXAMPLESchap05源码
💻 JAVA
字号:
//********************************************************************//  EvenOdd.java       Author: Lewis/Loftus////  Demonstrates the use of the JOptionPane class.//********************************************************************import javax.swing.JOptionPane;public class EvenOdd{   //-----------------------------------------------------------------   //  Determines if the value input by the user is even or odd.   //  Uses multiple dialog boxes for user interaction.   //-----------------------------------------------------------------   public static void main (String[] args)   {      String numStr, result;      int num, again;      do       {         numStr = JOptionPane.showInputDialog ("Enter an integer: ");         num = Integer.parseInt(numStr);         result = "That number is " + ((num%2 == 0) ? "even" : "odd");         JOptionPane.showMessageDialog (null, result);         again = JOptionPane.showConfirmDialog (null, "Do Another?");      }      while (again == JOptionPane.YES_OPTION);   }}

⌨️ 快捷键说明

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