Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.JOptionPane;
- public class t36noppa {
- public static void main(String[] args) {
- int kertaa;
- String str="", print="";
- str=JOptionPane.showInputDialog("Monta kertaa heitetään?");
- kertaa = Integer.parseInt(str);
- int[] noppa = new int [kertaa];
- int[] monta = new int [kertaa];
- for(int i=0;i<kertaa;i++){
- noppa[i]=(1 + (int)(Math.random() * 6))+(1 + (int)(Math.random() * 6));
- } // end of for
- for(int j=0;j<kertaa;j++){
- for(int k=2;k<13;k++){
- if(noppa[j]==k) {
- ++monta[k]; }
- }
- }
- for(int x=2;x<13;x++) {
- print += x+". "+monta[x]+" \n";
- }
- JOptionPane.showMessageDialog(null, print);
- } // end of class
- } // end of main
Add Comment
Please, Sign In to add comment