Guest User

Untitled

a guest
Jan 21st, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. import javax.swing.JOptionPane;
  2. public class t36noppa {
  3. public static void main(String[] args) {
  4. int kertaa;
  5. String str="", print="";
  6. str=JOptionPane.showInputDialog("Monta kertaa heitetään?");
  7. kertaa = Integer.parseInt(str);
  8. int[] noppa = new int [kertaa];
  9. int[] monta = new int [kertaa];
  10. for(int i=0;i<kertaa;i++){
  11. noppa[i]=(1 + (int)(Math.random() * 6))+(1 + (int)(Math.random() * 6));
  12. } // end of for
  13. for(int j=0;j<kertaa;j++){
  14. for(int k=2;k<13;k++){
  15. if(noppa[j]==k) {
  16. ++monta[k]; }
  17. }
  18. }
  19. for(int x=2;x<13;x++) {
  20. print += x+". "+monta[x]+" \n";
  21. }
  22. JOptionPane.showMessageDialog(null, print);
  23. } // end of class
  24. } // end of main
Add Comment
Please, Sign In to add comment