diff --git a/Examples/Dice.java b/Examples/Dice.java new file mode 100644 index 00000000..ec0a1682 --- /dev/null +++ b/Examples/Dice.java @@ -0,0 +1,23 @@ +import java.util.Scanner; + +public class Dice { + + public static void main(String[] args) { + + boolean b = true; + Scanner scanner = new Scanner(System.in); + + do { + System.out.println("Give input to roll the dice or write X to exit!"); + String a = scanner.next(); + if (a.toLowerCase().equals("x")) { + b = false; + } else { + System.out.println((int)(Math.random() * 6 + 1)); + } + } while(b); + scanner.close(); + + } + +}