zoukankan      html  css  js  c++  java
  • 课后作业3----加减乘除()

    //An addition program

    import javax.swing.JOptionPane; // import class JOptionPane

    public class Addition2 {
    public static void main( String args[] )
    {
    String firstNumber, // first string entered by user
    secondNumber; // second string entered by user
    int number1, // first number to add
    number2, // second number to add
    sum,cha,ji,shang; // sum of number1 and number2

    // read in first number from user as a string
    firstNumber =
    JOptionPane.showInputDialog( "Enter first integer" );

    // read in second number from user as a string
    secondNumber =
    JOptionPane.showInputDialog( "Enter second integer" );

    // convert numbers from type String to type int
    number1 = Integer.parseInt( firstNumber );
    number2 = Integer.parseInt( secondNumber );

    // add the numbers
    sum = number1 + number2;
    cha=number1-number2;
    ji=number1*number2;
    shang=number1/number2;
    // display the results
    JOptionPane.showMessageDialog(
    null, "The sum is " + sum, "Results",
    JOptionPane.PLAIN_MESSAGE );
    JOptionPane.showMessageDialog(
    null, "The cha is " + cha, "Results",
    JOptionPane.PLAIN_MESSAGE );
    JOptionPane.showMessageDialog(
    null, "The ji is " + ji, "Results",
    JOptionPane.PLAIN_MESSAGE );
    JOptionPane.showMessageDialog(
    null, "The shang is " + shang, "Results",
    JOptionPane.PLAIN_MESSAGE );
    System.exit( 0 ); // terminate the program
    }
    }

    https://necydcy.me/
  • 相关阅读:
    丸内の霊 補充4
    丸内の霊 補充3
    丸内の霊 補充2
    N1 语法单词
    完全掌握1级日本与能力考试语法问题对策
    丸の内の霊 補充1
    丸内の霊 8
    丸内の霊   7
    丸内の霊  6
    丸の内の霊 6
  • 原文地址:https://www.cnblogs.com/miria-486/p/7636368.html
Copyright © 2011-2022 走看看