Monty374

Exercise 9

Sep 28th, 2016
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. package exercise9;
  2.  
  3. import javax.swing.JOptionPane;
  4.  
  5.  
  6. /**
  7. *
  8. * @author Monty
  9. */
  10. public class Exercise9 {
  11.  
  12. /**
  13. * @param args the command line arguments
  14. */
  15. public static void main(String[] args) {
  16. String humanNum = JOptionPane.showInputDialog("Pick a number between 1-20");
  17. int hNumber = Integer.parseInt(humanNum);
  18. int compNumber = (int)(Math.random() * 20) + 1;
  19. System.out.println("Your number was " + hNumber);
  20. System.out.println("The computers Number Was "+ compNumber);
  21. if (hNumber == compNumber){
  22. System.out.println("Good Job, You got it right!");
  23. } else{
  24. System.out.println("Try Again");
  25. }
  26. }
  27.  
  28. }
Advertisement
Add Comment
Please, Sign In to add comment