Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package randnum;
- import javax.swing.JOptionPane;
- import java.lang.Math;
- /**
- *
- * @author Monty
- */
- public class Randnum {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- String innum1 = JOptionPane.showInputDialog("Input first number");
- int num1 = Integer.parseInt(innum1);
- String innum2 = JOptionPane.showInputDialog("Input a number that is greater than " + num1);
- int num2 = Integer.parseInt(innum2);
- double randNum = (num2 - num1 + 1) * Math.random() + num1;
- System.out.println("The middle number is: " +(int)(randNum));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment