K so I just started a comp sci class, and instead of trying to fix it myself, I'm going to ask you to! here the code:
import java.util.Random;
import java.util.Scanner;
public class MinMaxRandom {
public static void main (String [] args) {
Random randomnumber = new Random();//Use randomnumber to call the Random generator
Scanner source = new Scanner (System.in);//Use the name source in all scanner objects
int min;//the user inputted minimum
min = 0;
int max;//the user inputted maximum
max = 0;
int num1;//the final total
num1 = 0;
int total;//the number to input as the range of the random number
total= max - min + 1;
System.out.println ("This program is going to display a random number");
System.out.println ("between the numbers of your choosing");
System.out.println ("Please input the minimum number(Positive Please!)");
min = source.nextInt();
System.out.println ("Please input the maximum number");
max = source.nextInt();
num1 = randomnumber.nextInt( total ) + min +1;
System.out.println ( num1 );
}
}
the problem is the number at the end is ALWAYS one higher than the value for the minimum variable.
import java.util.Random;
import java.util.Scanner;
public class MinMaxRandom {
public static void main (String [] args) {
Random randomnumber = new Random();//Use randomnumber to call the Random generator
Scanner source = new Scanner (System.in);//Use the name source in all scanner objects
int min;//the user inputted minimum
min = 0;
int max;//the user inputted maximum
max = 0;
int num1;//the final total
num1 = 0;
int total;//the number to input as the range of the random number
total= max - min + 1;
System.out.println ("This program is going to display a random number");
System.out.println ("between the numbers of your choosing");
System.out.println ("Please input the minimum number(Positive Please!)");
min = source.nextInt();
System.out.println ("Please input the maximum number");
max = source.nextInt();
num1 = randomnumber.nextInt( total ) + min +1;
System.out.println ( num1 );
}
}
the problem is the number at the end is ALWAYS one higher than the value for the minimum variable.












» CBS daytime show aims to be 'The Talk' of the town
» How To Get New Skills In Maplestory
» Guides For Hunting In Maplestory
» Dragon Master Evan Class In Maplestory
» Tips On Aran In Maplestory
» DiCaprio's 'Inception' pounds 'Salt' at box office
» Guides On Maplestory Leveling
» Guides On Maplestory Leveling