import java.util.Random; import java.util.*; class roll{ public static void main(String[]args){ Scanner sc = new Scanner(System.in); Random rand = new Random(System.currentTimeMills()); int[] dice; int r,k,total,temp=-1; while(temp<=0){ //Determines number of "dice" to be rolled System.out.print("Enter the number of dice to be rolled: "); if(sc.hasNextInt()) temp=sc.nextInt(); } r=temp; temp=-1; while(temp<=0){ //Determines number of "dice" to be kept System.out.print("Please enter the number of dice to be kept: "); if(sc.hasNextInt()) temp=sc.nextInt(); if(temp>r){ //Checks if kept is greater than rolled temp=-1; System.out.println("Dice kept greater than dice rolled. "+r+" dice will be rolled."); } } k=temp; dice = new Int[r]; for(int i=0;irolls[i]){ int r=rolls[i+1]; rolls[i+1]=rolls[i]; rolls[i]=r; swapped=true; } } } } }