Java classic algorithm _ 005 ternary Operator

Source: Internet
Author: User

Question: Use nested conditional operators to complete this question: Students with scores> = 90 are represented by a, students with scores between 60 and 89 are represented by B, and students with scores below 60 are represented by C.

1.ProgramAnalysis: (A> B )? A: B is a basic example of conditional operators.

Package WZS. arithmetics; // question: Use nested conditional operators to complete this question: Students with scores> = 90 are represented by a, and students with scores between 60 and 89 are represented by B, the value below 60 is represented by C. // 1. program analysis: (A> B )? A: B is a basic example of conditional operators. Public class test_wzs5 {public static void main (string [] ARGs) {test_wzs5.f (99); test_wzs5.f (72); test_wzs5.f (50 );} /*** determine the interval * @ Param Number */public static void F (INT number) {string STR = (number> 90? "A": (number> 60? "B": "C"); system. Out. println (STR );}}

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.