Advertisement
Guest User

Untitled

a guest
Dec 1st, 2015
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package java_lab4;
  7.  
  8. import javax.swing.*;
  9. /**
  10. *
  11. * @author
  12. */
  13. public class Java_lab4_del1_a {
  14.  
  15. /**
  16. * @param args the command line arguments
  17. */
  18. public static void main(String[] args) {
  19.  
  20. String antalspelare = JOptionPane.showInputDialog("Antal spelare?");
  21. String antalkast = JOptionPane.showInputDialog("Antal tärningskast?");
  22. String resultat = "";
  23.  
  24. int spelare = Integer.parseInt(antalspelare);
  25. int kast = Integer.parseInt(antalkast);
  26. int raknare = 0;
  27. int raknare2 = 0;
  28.  
  29.  
  30.  
  31. for (raknare=1; raknare <= spelare; raknare = raknare+1){
  32. for (raknare2=1; raknare2 <= kast ; raknare2 = raknare2+1){
  33. int tarning = (int)Math.ceil(Math.random()*6);
  34. resultat = resultat + tarning +" ";
  35.  
  36.  
  37. }
  38.  
  39. JOptionPane.showMessageDialog(null, "Spelare: " + raknare + "\n" +
  40. "Antal kast: " + kast + "\nResultat: " + resultat + "");
  41. resultat = "";
  42.  
  43.  
  44. }
  45.  
  46.  
  47. }
  48.  
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement