Monty374

RandNum

Sep 28th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. package randnum;
  2.  
  3. import javax.swing.JOptionPane;
  4. import java.lang.Math;
  5.  
  6. /**
  7. *
  8. * @author Monty
  9. */
  10. public class Randnum {
  11.  
  12. /**
  13. * @param args the command line arguments
  14. */
  15. public static void main(String[] args) {
  16. String innum1 = JOptionPane.showInputDialog("Input first number");
  17. int num1 = Integer.parseInt(innum1);
  18. String innum2 = JOptionPane.showInputDialog("Input a number that is greater than " + num1);
  19. int num2 = Integer.parseInt(innum2);
  20.  
  21. double randNum = (num2 - num1 + 1) * Math.random() + num1;
  22. System.out.println("The middle number is: " +(int)(randNum));
  23. }
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment