Advertisement
HughesElite

Untitled

May 17th, 2021
559
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.26 KB | None | 0 0
  1. import java.util.Scanner;
  2. import java.util.ArrayList;
  3. import java.util.List;
  4. import java.util.Random;
  5.  
  6. public class ConfigTestArea
  7. {
  8.     public static void main(String[] args)
  9.     {
  10.         ConfigTestArea Obj = new ConfigTestArea();
  11.         Obj.go();
  12.  
  13.     }
  14.    
  15.     public void go()
  16.     {
  17.         Scanner scan = new Scanner(System.in);
  18.         Random rand = new Random();
  19.         int diceOneInt;
  20.         int diceTwoInt;
  21.         int rollTotal = 0;
  22.         List<Integer> diceResults = new ArrayList<Integer>();
  23.        
  24.         System.out.println("How many sides does the first dice have?");
  25.         diceOneInt = scan.nextInt();
  26.        
  27.         System.out.println("How many sides does the second dice have?");
  28.         diceTwoInt = scan.nextInt();
  29.         scan.close();
  30.        
  31.         while (rollTotal != 3)
  32.         {
  33.             int diceOneRoll = rand.nextInt(diceOneInt) +1;
  34.             diceResults.add(diceOneRoll);
  35.            
  36.             int diceTwoRoll = rand.nextInt (diceTwoInt) +1;
  37.             diceResults.add(diceTwoRoll);
  38.             rollTotal++;
  39.         }
  40.    
  41.         System.out.print("Your dice 1 results are " + (diceResults.get(0)));
  42.         System.out.print(", " + (diceResults.get(2)));
  43.         System.out.print(", " + (diceResults.get(4)));
  44.        
  45.         System.out.print("\nYour dice 2 results are " + (diceResults.get(1)));
  46.         System.out.print(", " + (diceResults.get(3)));
  47.         System.out.print(", " + (diceResults.get(5)));
  48.            
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement