Guess the game with Java!

Source: Internet
Author: User

Package com;

Import Java.util.Scanner;

public class Zixue007 {

public static void Main (string[] args) {
int b= (int) (Math.random () *10+1);
System.out.println (b);
Scanner input=new Scanner (system.in);
System.out.println ("Please enter a number within 1 to 10:");
int A=input.nextint ();
int i = 1;
int sum=0;
while (A!=b & i<10) {
System.out.println (a>b? ") Sorry: Big ":" Very sorry: small ");
System.out.println ("Please enter the Guess number again:");
A=input.nextint ();
i++;
sum++;
}
String s = "";
if (i<5) {
S= "You guessed right, the good, haha ha!" ";
}else if (i<9) {
S= "You guessed right, good grades";
}else s= "10 times can not guess the pig one";
System.out.println ("Congratulations on the correct number!") The "+" answer is: "+b+". You have guessed the "+i+" time. "
+ "The system evaluates you:" +s);




}
}

Guess the game with Java!

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.