Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Guess
- {
- public static void main(String [] args)
- {
- int wrong = 0;
- int right = 0;
- String check = "";
- while(check!= " Y")
- {
- Scanner key = new Scanner(System.in);
- int random = (int) (Math.random()*10)+1;
- System.out.print("Guess a number between 1-10");
- int num = key.nextInt();
- if(num<11 && num>0){
- if(num== random) {
- right++;
- System.out.println("Correct");
- }
- else if(num
- {
- wrong++;
- System.out.println("too low");
- }
- else
- {
- wrong++;
- System.out.println("too high");
- }
- }
- System.out.print("Would You like to Quit Enter(Y) ");
- check = key.next().toUpperCase;
- }
- System.out.println("Guessed Correctly :"+right+"/nGuessed Incorrectly :"+ wrong);
- System.out.println("Total Guessed :" + wrong+right);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement