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

📄 main.java

📁 4. Write a program that sorts three integers. The integers are entered from the console and stored i
💻 JAVA
字号:
/*
 * Main.java
 *
 * Created on 2007年8月4日, 下午1:48
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package javaapplication3;
import javax.swing.JOptionPane;
/**
 *
 * @author xue hao
 */
public class Main {
    
    /** Creates a new instance of Main */
    public Main() {
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
   //1.  Generate two random stingle-digit integers
    int number1 = (int)(Math.random() * 10);
    int number2 = (int)(Math.random() * 10);
    
   //2. Prompt the student to answer "what is number1 + number2?"
    String answerString = JOptionPane.showInputDialog
      ("what is " + number1 + " + " + number2 + "?");
     int answer = Integer.parseInt(answerString);

    //3. Grade the answer and display the result 
    String jackie;
    if ( number1 + number2 == answer  )
      jackie = " you are correct ";
    else 
   jackie = " your answer is wrong .\n " + number1 + " + " + number2 + " should be " + (number1 + number2);
    JOptionPane.showMessageDialog(null, jackie);
    }
    
}

⌨️ 快捷键说明

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