Guest User

Untitled

a guest
Nov 17th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. package dadosrpg;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class DadosRPG {
  6.  
  7. public static void main(String[] args) {
  8. Scanner entrada = new Scanner(System.in);
  9. int dado = 0;
  10. int d2 = (int) (Math.random() * 2 + 1);
  11. int d4 = (int) (Math.random() * 4 + 1);
  12. int d6 = (int) (Math.random() * 6 + 1);
  13. int d8 = (int) (Math.random() * 8 + 1);
  14. int d10 = (int) (Math.random() * 10 + 1);
  15. int d12 = (int) (Math.random() * 12 + 1);
  16. int d20 = (int) (Math.random() * 20 + 1);
  17. int d100 = (int) (Math.random() * 100 + 1);
  18. System.out.println("Qual dado você quer jogar? (apenas dígitos: 2, 4, 6, 8, 10, 12, 20 ou 100.)");
  19. dado = entrada.nextInt();
  20. if (dado == 2) {
  21. System.out.println("d2: " + d2);
  22. } else if (dado == 4) {
  23. System.out.println("d4: " + d4);
  24. } else if (dado == 6) {
  25. System.out.println("d6: " + d6);
  26. } else if (dado == 8) {
  27. System.out.println("d8: " + d8);
  28. } else if (dado == 10) {
  29. System.out.println("d10: " + d10);
  30. } else if (dado == 12) {
  31. System.out.println("d12: " + d12);
  32. } else if (dado == 20) {
  33. System.out.println("d20: " + d20);
  34. } else if (dado == 100) {
  35. System.out.println("d100: " + d100);
  36. } else {
  37. System.out.println("Valor incorreto, digite apenas: 2, 4, 6, 8, 10, 12, 20 ou 100.");
  38. }
  39. }
  40. }
Add Comment
Please, Sign In to add comment