I’m writing a program that is supposed to generate four random integers (from 1 to 6), then discard the lowest value and add the remaining three together. I created four variables with
int var1 = rand.nextInt(6)+1;
int var2 = rand.nextInt(6)+1;
int var3 = rand.nextInt(6)+1;
int var4 = rand.nextInt(6)+1;
How would I get the program to detect the smallest variable? (or the variable tied for smallest) I think I may have a method, but it would be very long and tedious to write and I’m sure there’s a simpler way that I’m just not realizing.
Don’t bother detecting until after the add.