Advertisement
Guest User

Untitled

a guest
Dec 4th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3.  
  4. public class Main {
  5.  
  6. public static void main(String[] args) {
  7. Scanner user_input = new Scanner(System.in);
  8. One_dice oneDice = new One_dice();
  9. Two_dice twoDice = new Two_dice();
  10. boolean exit = false;
  11. System.out.println("Welcome to the Dice Roll Calculator!");
  12.  
  13. while (exit == false)
  14. {
  15. System.out.println("Would you like to roll a dice? y/n");
  16. String input = user_input.nextLine();
  17. if (input.equals("y"))
  18. {
  19. System.out.println("How many sides do you want on "
  20. + "your dice?");
  21. int userSize = user_input.nextInt();
  22. oneDice.SetDiceRoll(userSize);
  23.  
  24. System.out.println("The result was: " +
  25. oneDice.GetDiceValue());
  26.  
  27. System.out.println("Would you like to roll two dice? y/n");
  28. user_input.nextLine();
  29. if (input.equals("y"))
  30. {
  31. System.out.println("How many sides do you want on "
  32. + "your dice?");
  33. int userSize2 = user_input.nextInt();
  34. oneDice.SetDiceRoll(userSize2);
  35. twoDice.SetDiceRoll(userSize2);
  36.  
  37. System.out.println("The result was: " +
  38. oneDice.GetDiceValue() + " and " + twoDice.GetDiceValue());
  39. }
  40. }
  41. else
  42. {
  43. System.out.println("You chose not to roll. "
  44. + "Would you like to exit the program?");
  45. input = user_input.nextLine();
  46. if (input.equals("y"))
  47. {
  48. exit = true;
  49. }
  50. }
  51. }
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement