Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package dadosrpg;
- import java.util.Scanner;
- public class DadosRPG {
- public static void main(String[] args) {
- Scanner entrada = new Scanner(System.in);
- int dado = 0;
- int d2 = (int) (Math.random() * 2 + 1);
- int d4 = (int) (Math.random() * 4 + 1);
- int d6 = (int) (Math.random() * 6 + 1);
- int d8 = (int) (Math.random() * 8 + 1);
- int d10 = (int) (Math.random() * 10 + 1);
- int d12 = (int) (Math.random() * 12 + 1);
- int d20 = (int) (Math.random() * 20 + 1);
- int d100 = (int) (Math.random() * 100 + 1);
- System.out.println("Qual dado você quer jogar? (apenas dígitos: 2, 4, 6, 8, 10, 12, 20 ou 100.)");
- dado = entrada.nextInt();
- if (dado == 2) {
- System.out.println("d2: " + d2);
- } else if (dado == 4) {
- System.out.println("d4: " + d4);
- } else if (dado == 6) {
- System.out.println("d6: " + d6);
- } else if (dado == 8) {
- System.out.println("d8: " + d8);
- } else if (dado == 10) {
- System.out.println("d10: " + d10);
- } else if (dado == 12) {
- System.out.println("d12: " + d12);
- } else if (dado == 20) {
- System.out.println("d20: " + d20);
- } else if (dado == 100) {
- System.out.println("d100: " + d100);
- } else {
- System.out.println("Valor incorreto, digite apenas: 2, 4, 6, 8, 10, 12, 20 ou 100.");
- }
- }
- }
Add Comment
Please, Sign In to add comment