Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Random;
- import java.util.InputMismatchException;
- public class ConfigTestArea
- {
- public static void main(String[] args)
- {
- ConfigTestArea Obj = new ConfigTestArea();
- Obj.go();
- }
- public void go()
- {
- Scanner scan = new Scanner(System.in);
- Random rand = new Random();
- int diceOneInt;
- int diceTwoInt;
- int rollTotal = 0;
- List<Integer> diceResults = new ArrayList<Integer>();
- try {
- System.out.println("How many sides does the first dice have?");
- diceOneInt = scan.nextInt();
- System.out.println("How many sides does the second dice have?");
- diceTwoInt = scan.nextInt();
- } catch (InputMismatchException e) {
- System.out.println("no");
- scan.close();
- while (rollTotal != 3)
- {
- int diceOneRoll = rand.nextInt(diceOneInt) +1;
- diceResults.add(diceOneRoll);
- int diceTwoRoll = rand.nextInt (diceTwoInt) +1;
- diceResults.add(diceTwoRoll);
- rollTotal++;
- }
- System.out.print("Dice 1 rolls " + (diceResults.get(0)));
- System.out.print(", " + (diceResults.get(2)));
- System.out.print(", " + (diceResults.get(4)));
- System.out.print("\nDice 2 rolls " + (diceResults.get(1)));
- System.out.print(", " + (diceResults.get(3)));
- System.out.print(", " + (diceResults.get(5)));
- System.out.print("\nDice one rolls a total of ");
- System.out.print(diceResults.get(0) + (diceResults.get(2) + diceResults.get(4)));
- System.out.print("\nDice two rolls a total of ");
- System.out.print(diceResults.get(1) + (diceResults.get(3) + diceResults.get(5)));
- System.out.print("\nDice one rolls an average of ");
- System.out.print((diceResults.get(0) + (diceResults.get(2) + diceResults.get(4))) /3.0);
- System.out.print("\nDice two rolls an average of ");
- System.out.print((diceResults.get(1) + (diceResults.get(3) + diceResults.get(5))) /3.0);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement