After-school homework (due to blog source issues, sent the mailbox job, resubmit the blog park)

Source: Internet
Author: User

1, write a program, the user input two number, to find out its subtraction, and the message box display calculation results.

Source code://yewen Wang 2015.10.04

Package JS;

Import Javax.swing.JOptionPane;

public class JIS {

public static void Main (string[] args) {

TODO auto-generated Method Stub

String Firstnum,secondnum; Manually enter a two number

int num1,num2,sum,jian,ch,div; Two numbers and subtraction

Firstnum=joptionpane.showinputdialog ("Enter first integer");

Secondnum=joptionpane.showinputdialog ("Enter first integer");

Num1=integer.parseint (Firstnum);

Num2=integer.parseint (Secondnum);

sum=num1+num2;

Joptionpane.showmessagedialog (

NULL, "Sum of two numbers is:" + sums, "Results",

Joptionpane.plain_message);

jian=num1-num2;

Joptionpane.showmessagedialog (

NULL, "Two number subtraction is:" + Jian, "Results",

Joptionpane.plain_message);

ch=num1*num2;

Joptionpane.showmessagedialog (

NULL, "Multiply two number is:" + ch, "Results",

Joptionpane.plain_message);

div=num1/num2;

Joptionpane.showmessagedialog (

NULL, "Two-digit phase is in addition to:" + div, "Results",

Joptionpane.plain_message);

System.exit (0);

}

}

1, the course of all hands-on brain problems and after-school experimental problems, organized into a document, blog in the form of the blog in the Garden

(1) Read the example carefully : Enumtest.java, run it, analyze the running results?

Results:

(2) What conclusions can you get? Have you mastered the basic usage of enum types?

My conclusion is:

A, enum type is a reference type

B, the enumeration type does not belong to the original data type, each of its specific values refers to a specific object, and the same value refers to the same object.

C, you can use "= =" and equals () to directly compare the value of the enumeration variable, in other words, for the enumeration type of variables, "= =" and The result of the equals () method execution is equivalent.

3, read the corresponding textbooks, or use the Internet search engine, find out the anti-code, complement and the original code of the concepts, and then write a sample program, the positive numbers, negative numbers for a variety of bit operations, observe the output, and the results of the manual calculation, to see the Java The number in the above is expressed by which code.

Original code: The original code is the binary vertex notation, that is, the highest bit is the sign bit, "0" is positive, "1" is negative, the remaining bits represent the size of the value.

Anti-code: The inverse code of positive number is the same as the original code, negative inverse code, the sign bit is "1", the numerical part is reversed by the position

Complement: The complement of a positive number is the same as its original code, the complement of negative number is in its inverse code of the last plus one.

Java is represented by a complement

4. Java variables follow the "masking principle of the same name variable", please read the relevant information after class to find out the relevant knowledge, and then write some test code, as in this example, consciously defined in different places with the same name variable, to see exactly what the output is.

When a variable has the same name, some variables are masked.

In Java, if the local variable name is the same as the member variable name, the member variable is masked and the This operator is used if you want to use a member variable .

After-school homework (due to blog source issues, sent the mailbox job, resubmit the blog park)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.