20141013 -- judgment Statement (if, else)

Source: Internet
Author: User

So far, the previous programs can only be executed step by step.

Statement: Judge and loop to form program branches and loops.

Select Control: If, else, switch, Case

Loop Control: white, do, for, foreach

Jump statement: Break, continue

Exception Handling: Try, catch, finally

If is equivalent to a conditional OPERATOR:

Example

Else: Also

For example, judge whether a number is a two-digit integer.

If else nesting:

Enter the name and score to determine whether the score is successful,

If the value is greater than or equal to 80, "you have learned a good job and are worthy of praise !"

If it is less than 50, the output will be "hard work, don't be lazy !"

If the output is between 50 and 60, the output will be "just a little bit !"

Enter a decimal number and then round it to five:

Because it is a decimal number, you need to define the floating point type:

Take double as an example,

Read the input value A, subtract the integer a from the floating point A, and then judge the relationship between the value and the value 0.5.

That is, double A = double. parse (console. realine ());

Double C = A-(INT);

If C is greater than or equal to 0.5, 1 is entered. If C is less than 0.5, decimal places are removed.

Apply to definition, integer and floating point conversion, and other knowledge (with increasing increments)

Then

Equation: ax2 + bx + c = 0

Determine the root of the equation and solve it:

First, understand what is a quadratic equation,

If a is equal to 0, the equation is not a quadratic equation.

Use the formula: louta △ = b2-4 * a * C to judge the root condition:

△< 0 then the equation has no solution, △= 0 has two equal solid roots, and △> 0 has two different solid roots.

Another formula is used for solving the problem:

X = (-B ± √ b2-4ac)/(2 *)

√ The function math. SQRT () is required ()

Standard Weight:

Men's Weight = height-100 + 3, Women's Weight = height-110 + 3

The formula is changed to: Men's weight-height + 100 = ± 3 women's weight-height + 110 = ± 3

 

20141013 -- judgment Statement (if, else)

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.