Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package exercise9;
- import javax.swing.JOptionPane;
- /**
- *
- * @author Monty
- */
- public class Exercise9 {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- String humanNum = JOptionPane.showInputDialog("Pick a number between 1-20");
- int hNumber = Integer.parseInt(humanNum);
- int compNumber = (int)(Math.random() * 20) + 1;
- System.out.println("Your number was " + hNumber);
- System.out.println("The computers Number Was "+ compNumber);
- if (hNumber == compNumber){
- System.out.println("Good Job, You got it right!");
- } else{
- System.out.println("Try Again");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment