daily pastebin goal
25%
SHARE
TWEET

Untitled

a guest Oct 12th, 2017 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. public class Guess
  4.  
  5. {
  6.  
  7.   public static void main(String [] args)  
  8.  
  9. {    
  10. int wrong = 0;
  11. int right = 0;
  12. String check = "";
  13.  
  14. while(check!= " Y")
  15. {
  16.   Scanner key = new Scanner(System.in);      
  17.  
  18. int random = (int) (Math.random()*10)+1;      
  19.  
  20. System.out.print("Guess a number between 1-10");      
  21.  
  22. int num = key.nextInt();      
  23.  
  24. if(num<11 && num>0){
  25.  
  26. if(num== random)        {          
  27. right++;
  28. System.out.println("Correct");      
  29.  
  30. }
  31.  
  32. else  if(num
  33. {          
  34. wrong++;
  35.                 System.out.println("too low");        
  36.  
  37.   }        
  38.  
  39.   else        
  40.  
  41.   {              
  42. wrong++;
  43.        System.out.println("too high");  
  44.  
  45.      }  
  46.  
  47. }
  48.  
  49. System.out.print("Would You like to Quit Enter(Y) ");
  50.  
  51. check  = key.next().toUpperCase;
  52.  
  53. }
  54. System.out.println("Guessed Correctly :"+right+"/nGuessed Incorrectly :"+ wrong);
  55. System.out.println("Total Guessed :" + wrong+right);
  56. }
RAW Paste Data
Top