Design a method and enter a number to return a result

Source: Internet
Author: User

Tag: Port sys New returns the number of break next Test Shu

/* Do a function, I pass a number to you, you return a result to me.
* Requirements: If the number is less than 100, the actual input number is returned;
* If greater than 100 is less than 200, then return ' 100+ ';
* If greater than 200 is less than 300, return ' 200+ ';
*/
Package homework;

Import Java.util.Scanner;

public class Shuzi {
public void Shuzu () {
Scanner input = new Scanner (system.in);
System.out.println ("Please enter a number:");

int id = input.nextint ();
if (ID < 0)
SYSTEM.OUT.PRINTLN ("Your input is wrong");

while (ID < 100) {
if (ID < && ID > 0) {
SYSTEM.OUT.PRINTLN (ID);
Break
}
}
while (ID > 100) {
int n1 = id/100;
if (ID > (n1 *) && ID < ((n1 + 1) * 100)) {
System.out.println ((+N1) * 100 + "+");
Break
}

}

}

public static void Main (string[] args) {
Shuzi test = new Shuzi ();
Test.shuzu ();

}

}

Enter 12 to run the result:

Please enter a number:1212

Enter 230 to run the result:

Please enter a number:230200+

Input-2, run the result:

Please enter a number:-2 Your input is wrong

Design a method and enter a number to return a result

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.