Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class MyClass {
- public static void main(String args[]) {
- int random = (int)(Math.random() * 10 + 1);
- int guess_count = 0;
- System.out.println("Guess the number from 1 - 10");
- int correct = 0;
- int guess = 0;
- System.out.println(random);
- Scanner sc = new Scanner(System.in);
- do{
- System.out.print("Enter your number: ");
- guess = sc.nextInt();
- if(guess == random)
- {
- correct = 1;
- }
- else if (guess < random){
- System.out.println("Wrong! Higher pa bes\n");
- }else if(guess > random){
- System.out.println("Wrong! Lower madam\n");
- }
- }while(correct == 0);
- System.out.println("\n\nCongratulations! You guess the correct number");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement