"Java" is an interesting number game.

Source: Internet
Author: User

1  Packagecom.xt.homework.hw09;2 ImportJava.util.Scanner;3 /**4 * 4. Guess the number game. Randomly generates an integer of 1-100,5 * Let the user guess, guess big (or guess small) have a hint;6 * Until the user guesses the right, the prompt succeeds, the program ends. 7  * 8  * @authorTin Yiu Phase two9 * Yang BulongTen  */ One      Public classHomeWork04 { A      Public Static voidMain (string[] args) { -     Doubleb =math.random (); -b*=100; the      if((int) (b+0.5) > (int) b) { -B= (int) b+1;} -      Else{ -B= (int) b;} +       while(1==1){ -System.out.println ("Please enter the number you guessed:"); +Scanner scan =NewScanner (system.in); A     intA =scan.nextint (); at     if(a>b) { -SYSTEM.OUT.PRINTLN ("---you guessed---");} -     if(a<b) { -SYSTEM.OUT.PRINTLN ("---you guessed---");} -     if(a==b) { -System.out.println ("+ + Congratulations, guessed right + +"); in          Break;} -         } to}

Boring learning, playing games is also very good!

"Java" is an interesting number game.

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.