Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package dieroller;
- import javax.swing.JOptionPane;
- /**33
- *
- * @author Conor
- */
- public class DieRoller {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- String input1;
- String input2;
- double result1 = 0;
- double result2 = 0;
- double result3 = 0;
- double result4 = 0;
- double result5 = 0;
- double result6 = 0;
- double sum;
- for(int i=0; i <5; i++){
- input1 = JOptionPane.showInputDialog("Enter in the amount of die you would like to roll:");
- input2 = JOptionPane.showInputDialog("Enter in the amount of sides on the die:");
- switch(input1){
- case "1":
- switch (input2) {
- case "100":
- result1 = Math.floor((Math.random()*100)+1);
- break;
- case "2":
- result1 = Math.floor((Math.random()*2)+1);
- break;
- case "3":
- result1 = Math.floor((Math.random()*3)+1);
- break;
- case "4":
- result1 = Math.floor((Math.random()*4)+1);
- break;
- case "5":
- result1 = Math.floor((Math.random()*5)+1);
- break;
- case "6":
- result1 = Math.floor((Math.random()*6)+1);
- break;
- case "8":
- result1 = Math.floor((Math.random()*8)+1);
- break;
- case "10":
- result1 = Math.floor((Math.random()*10)+1);
- break;
- case "12":
- result1 = Math.floor((Math.random()*12)+1);
- break;
- case "20":
- result1 = Math.floor((Math.random()*20)+1);
- break;
- }
- break;
- case "2":
- switch (input2) {
- case "100":
- result1 = Math.floor((Math.random()*100)+1);
- result2 = Math.floor((Math.random()*100)+1);
- break;
- case "2":
- result1 = Math.floor((Math.random()*2)+1);
- result2 = Math.floor((Math.random()*2)+1);
- break;
- case "3":
- result1 = Math.floor((Math.random()*3)+1);
- result2 = Math.floor((Math.random()*3)+1);
- break;
- case "4":
- result1 = Math.floor((Math.random()*4)+1);
- result2 = Math.floor((Math.random()*4)+1);
- break;
- case "5":
- result1 = Math.floor((Math.random()*5)+1);
- result2 = Math.floor((Math.random()*5)+1);
- break;
- case "6":
- result1 = Math.floor((Math.random()*6)+1);
- result2 = Math.floor((Math.random()*6)+1);
- break;
- case "8":
- result1 = Math.floor((Math.random()*8)+1);
- result2 = Math.floor((Math.random()*8)+1);
- break;
- case "10":
- result1 = Math.floor((Math.random()*10)+1);
- result2 = Math.floor((Math.random()*10)+1);
- break;
- case "12":
- result1 = Math.floor((Math.random()*12)+1);
- result2 = Math.floor((Math.random()*12)+1);
- break;
- case "20":
- result1 = Math.floor((Math.random()*20)+1);
- result2 = Math.floor((Math.random()*20)+1);
- break;
- }
- break;
- case "3":
- switch (input2) {
- case "100":
- result1 = Math.floor((Math.random()*100)+1);
- result2 = Math.floor((Math.random()*100)+1);
- result3 = Math.floor((Math.random()*100)+1);
- break;
- case "2":
- result1 = Math.floor((Math.random()*2)+1);
- result2 = Math.floor((Math.random()*2)+1);
- result3 = Math.floor((Math.random()*2)+1);
- break;
- case "3":
- result1 = Math.floor((Math.random()*3)+1);
- result2 = Math.floor((Math.random()*3)+1);
- result3 = Math.floor((Math.random()*3)+1);
- break;
- case "4":
- result1 = Math.floor((Math.random()*4)+1);
- result2 = Math.floor((Math.random()*4)+1);
- result3 = Math.floor((Math.random()*4)+1);
- break;
- case "5":
- result1 = Math.floor((Math.random()*5)+1);
- result2 = Math.floor((Math.random()*5)+1);
- result3 = Math.floor((Math.random()*5)+1);
- break;
- case "6":
- result1 = Math.floor((Math.random()*6)+1);
- result2 = Math.floor((Math.random()*6)+1);
- result3 = Math.floor((Math.random()*6)+1);
- break;
- case "8":
- result1 = Math.floor((Math.random()*8)+1);
- result2 = Math.floor((Math.random()*8)+1);
- result3 = Math.floor((Math.random()*8)+1);
- break;
- case "10":
- result1 = Math.floor((Math.random()*10)+1);
- result2 = Math.floor((Math.random()*10)+1);
- result3 = Math.floor((Math.random()*10)+1);
- break;
- case "12":
- result1 = Math.floor((Math.random()*12)+1);
- result2 = Math.floor((Math.random()*12)+1);
- result3 = Math.floor((Math.random()*12)+1);
- break;
- case "20":
- result1 = Math.floor((Math.random()*20)+1);
- result2 = Math.floor((Math.random()*20)+1);
- result3 = Math.floor((Math.random()*20)+1);
- break;
- }
- case "4":
- switch (input2) {
- case "100":
- result1 = Math.floor((Math.random()*100)+1);
- result2 = Math.floor((Math.random()*100)+1);
- result3 = Math.floor((Math.random()*100)+1);
- result4 = Math.floor((Math.random()*100)+1);
- break;
- case "2":
- result1 = Math.floor((Math.random()*2)+1);
- result2 = Math.floor((Math.random()*2)+1);
- result3 = Math.floor((Math.random()*2)+1);
- result4 = Math.floor((Math.random()*2)+1);
- break;
- case "3":
- result1 = Math.floor((Math.random()*3)+1);
- result2 = Math.floor((Math.random()*3)+1);
- result3 = Math.floor((Math.random()*3)+1);
- result4 = Math.floor((Math.random()*3)+1);
- break;
- case "4":
- result1 = Math.floor((Math.random()*4)+1);
- result2 = Math.floor((Math.random()*4)+1);
- result3 = Math.floor((Math.random()*4)+1);
- result4 = Math.floor((Math.random()*4)+1);
- break;
- case "5":
- result1 = Math.floor((Math.random()*5)+1);
- result2 = Math.floor((Math.random()*5)+1);
- result3 = Math.floor((Math.random()*5)+1);
- result4 = Math.floor((Math.random()*5)+1);
- break;
- case "6":
- result1 = Math.floor((Math.random()*6)+1);
- result2 = Math.floor((Math.random()*6)+1);
- result3 = Math.floor((Math.random()*6)+1);
- result4 = Math.floor((Math.random()*6)+1);
- break;
- case "8":
- result1 = Math.floor((Math.random()*8)+1);
- result2 = Math.floor((Math.random()*8)+1);
- result3 = Math.floor((Math.random()*8)+1);
- result4 = Math.floor((Math.random()*8)+1);
- break;
- case "10":
- result1 = Math.floor((Math.random()*10)+1);
- result2 = Math.floor((Math.random()*10)+1);
- result3 = Math.floor((Math.random()*10)+1);
- result4 = Math.floor((Math.random()*10)+1);
- break;
- case "12":
- result1 = Math.floor((Math.random()*12)+1);
- result2 = Math.floor((Math.random()*12)+1);
- result3 = Math.floor((Math.random()*12)+1);
- result4 = Math.floor((Math.random()*12)+1);
- break;
- case "20":
- result1 = Math.floor((Math.random()*20)+1);
- result2 = Math.floor((Math.random()*20)+1);
- result3 = Math.floor((Math.random()*20)+1);
- result4 = Math.floor((Math.random()*20)+1);
- break;
- }
- case "5":
- switch (input2) {
- case "100":
- result1 = Math.floor((Math.random()*100)+1);
- result2 = Math.floor((Math.random()*100)+1);
- result3 = Math.floor((Math.random()*100)+1);
- result4 = Math.floor((Math.random()*100)+1);
- result5 = Math.floor((Math.random()*100)+1);
- break;
- case "2":
- result1 = Math.floor((Math.random()*2)+1);
- result2 = Math.floor((Math.random()*2)+1);
- result3 = Math.floor((Math.random()*2)+1);
- result4 = Math.floor((Math.random()*2)+1);
- result5 = Math.floor((Math.random()*2)+1);
- break;
- case "3":
- result1 = Math.floor((Math.random()*3)+1);
- result2 = Math.floor((Math.random()*3)+1);
- result3 = Math.floor((Math.random()*3)+1);
- result4 = Math.floor((Math.random()*3)+1);
- result5 = Math.floor((Math.random()*3)+1);
- break;
- case "4":
- result1 = Math.floor((Math.random()*4)+1);
- result2 = Math.floor((Math.random()*4)+1);
- result3 = Math.floor((Math.random()*4)+1);
- result4 = Math.floor((Math.random()*4)+1);
- result5 = Math.floor((Math.random()*4)+1);
- break;
- case "5":
- result1 = Math.floor((Math.random()*5)+1);
- result2 = Math.floor((Math.random()*5)+1);
- result3 = Math.floor((Math.random()*5)+1);
- result4 = Math.floor((Math.random()*5)+1);
- result5 = Math.floor((Math.random()*5)+1);
- break;
- case "6":
- result1 = Math.floor((Math.random()*6)+1);
- result2 = Math.floor((Math.random()*6)+1);
- result3 = Math.floor((Math.random()*6)+1);
- result4 = Math.floor((Math.random()*6)+1);
- result5 = Math.floor((Math.random()*6)+1);
- break;
- case "8":
- result1 = Math.floor((Math.random()*8)+1);
- result2 = Math.floor((Math.random()*8)+1);
- result3 = Math.floor((Math.random()*8)+1);
- result4 = Math.floor((Math.random()*8)+1);
- result5 = Math.floor((Math.random()*8)+1);
- break;
- case "10":
- result1 = Math.floor((Math.random()*10)+1);
- result2 = Math.floor((Math.random()*10)+1);
- result3 = Math.floor((Math.random()*10)+1);
- result4 = Math.floor((Math.random()*10)+1);
- result5 = Math.floor((Math.random()*10)+1);
- break;
- case "12":
- result1 = Math.floor((Math.random()*12)+1);
- result2 = Math.floor((Math.random()*12)+1);
- result3 = Math.floor((Math.random()*12)+1);
- result4 = Math.floor((Math.random()*12)+1);
- result5 = Math.floor((Math.random()*12)+1);
- break;
- case "20":
- result1 = Math.floor((Math.random()*20)+1);
- result2 = Math.floor((Math.random()*20)+1);
- result3 = Math.floor((Math.random()*20)+1);
- result4 = Math.floor((Math.random()*20)+1);
- result5 = Math.floor((Math.random()*20)+1);
- break;
- }
- case "6":
- switch (input2) {
- case "100":
- result1 = Math.floor((Math.random()*100)+1);
- result2 = Math.floor((Math.random()*100)+1);
- result3 = Math.floor((Math.random()*100)+1);
- result4 = Math.floor((Math.random()*100)+1);
- result5 = Math.floor((Math.random()*100)+1);
- result6 = Math.floor((Math.random()*100)+1);
- break;
- case "2":
- result1 = Math.floor((Math.random()*2)+1);
- result2 = Math.floor((Math.random()*2)+1);
- result3 = Math.floor((Math.random()*2)+1);
- result4 = Math.floor((Math.random()*2)+1);
- result5 = Math.floor((Math.random()*2)+1);
- result6 = Math.floor((Math.random()*2)+1);
- break;
- case "3":
- result1 = Math.floor((Math.random()*3)+1);
- result2 = Math.floor((Math.random()*3)+1);
- result3 = Math.floor((Math.random()*3)+1);
- result4 = Math.floor((Math.random()*3)+1);
- result5 = Math.floor((Math.random()*3)+1);
- result6 = Math.floor((Math.random()*3)+1);
- break;
- case "4":
- result1 = Math.floor((Math.random()*4)+1);
- result2 = Math.floor((Math.random()*4)+1);
- result3 = Math.floor((Math.random()*4)+1);
- result4 = Math.floor((Math.random()*4)+1);
- result5 = Math.floor((Math.random()*4)+1);
- result6 = Math.floor((Math.random()*4)+1);
- break;
- case "5":
- result1 = Math.floor((Math.random()*5)+1);
- result2 = Math.floor((Math.random()*5)+1);
- result3 = Math.floor((Math.random()*5)+1);
- result4 = Math.floor((Math.random()*5)+1);
- result5 = Math.floor((Math.random()*5)+1);
- result6 = Math.floor((Math.random()*5)+1);
- break;
- case "6":
- result1 = Math.floor((Math.random()*6)+1);
- result2 = Math.floor((Math.random()*6)+1);
- result3 = Math.floor((Math.random()*6)+1);
- result4 = Math.floor((Math.random()*6)+1);
- result5 = Math.floor((Math.random()*6)+1);
- result6 = Math.floor((Math.random()*6)+1);
- break;
- case "8":
- result1 = Math.floor((Math.random()*8)+1);
- result2 = Math.floor((Math.random()*8)+1);
- result3 = Math.floor((Math.random()*8)+1);
- result4 = Math.floor((Math.random()*8)+1);
- result5 = Math.floor((Math.random()*8)+1);
- result6 = Math.floor((Math.random()*8)+1);
- break;
- case "10":
- result1 = Math.floor((Math.random()*10)+1);
- result2 = Math.floor((Math.random()*10)+1);
- result3 = Math.floor((Math.random()*10)+1);
- result4 = Math.floor((Math.random()*10)+1);
- result5 = Math.floor((Math.random()*10)+1);
- result6 = Math.floor((Math.random()*10)+1);
- break;
- case "12":
- result1 = Math.floor((Math.random()*12)+1);
- result2 = Math.floor((Math.random()*12)+1);
- result3 = Math.floor((Math.random()*12)+1);
- result4 = Math.floor((Math.random()*12)+1);
- result5 = Math.floor((Math.random()*12)+1);
- result6 = Math.floor((Math.random()*12)+1);
- break;
- case "20":
- result1 = Math.floor((Math.random()*20)+1);
- result2 = Math.floor((Math.random()*20)+1);
- result3 = Math.floor((Math.random()*20)+1);
- result4 = Math.floor((Math.random()*20)+1);
- result5 = Math.floor((Math.random()*20)+1);
- result6 = Math.floor((Math.random()*20)+1);
- break;
- }
- }
- switch (input1) {
- case "1":
- JOptionPane.showMessageDialog(null,"You rolled a "+ result1);
- break;
- case "2":
- sum = result1 + result2;
- JOptionPane.showMessageDialog(null,"You rolled a " + result1 + "\n and a " +result2+"\n\n Total: "+sum);
- break;
- case "3":
- sum = result1 + result2 + result3;
- JOptionPane.showMessageDialog(null,"You rolled a " + result1 + "\n and a " +result2+ "\n and a " +result3+"\n\n Total: "+sum);
- break;
- case "4":
- sum = result1 + result2 + result3 + result4;
- JOptionPane.showMessageDialog(null,"You rolled a " + result1 + "\n and a " +result2+ "\n and a " +result3+ "\n and a " +result4+"\n\n Total: "+sum);
- break;
- case "5":
- sum = result1 + result2 + result3 + result4 + result5;
- JOptionPane.showMessageDialog(null,"You rolled a " + result1 + "\n and a " +result2+ "\n and a " +result3+ "\n and a " +result4+ "\n and a " +result5+"\n\n Total: "+sum);
- break;
- case "6":
- sum = result1 + result2 + result3 + result4 + result5 + result6;
- JOptionPane.showMessageDialog(null,"You rolled a " + result1 + "\n and a " +result2+ "\n and a " +result3+ "\n and a " +result4+ "\n and a " +result5+ "\n and a " +result6+"\n\n Total: "+sum);
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement