Advertisement
Guest User

Untitled

a guest
Aug 30th, 2017
529
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.58 KB | None | 0 0
  1. import java.util.Random;
  2. import java.util.Scanner;
  3.  
  4. class main{
  5.     public static void main(String args[]){
  6.         Scanner deer = new Scanner(System.in);
  7.         Random gmn = new Random();
  8.        
  9.         double numb;
  10.         double jagnumb;
  11.         System.out.println("I am thinking of a number between 1 and 10. Can you guess it?");
  12.         jagnumb = deer.nextDouble();
  13.        
  14.         for(double counter=1;counter<=1;counter++){
  15.             numb = 1+gmn.nextInt(10);
  16.             if(jagnumb == numb){
  17.             System.out.println("You guessed the number!");
  18.         }else{
  19.             System.out.println("Sorry, you were wrong! The number was " + numb + ".");
  20.         } }
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement