Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.William;
- import java.util.*;
- public class gangstasName
- {
- public static void main(String[] args)
- {
- Random random = new Random();
- int number = random.nextInt(10) + 1;
- Scanner input = new Scanner(System.in);
- System.out.print("guess a number between 1 and 10");
- int guess = input.nextInt();
- int wrongHowClose = number-guess;
- int howClose = Math.abs(wrongHowClose);
- if(guess < 1 || guess > 10)
- {
- System.out.print("that is an invalid number");
- System.exit(0);
- }
- if (guess == number)
- {
- System.out.print("im proud of you");
- }
- else {
- if (howClose >= 3) {
- System.out.println("you were so far off");
- } else
- {
- System.out.println("so close");
- }
- System.out.print("better luck next time");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement