Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package java_lab4;
- import javax.swing.*;
- /**
- *
- * @author
- */
- public class Java_lab4_del1_a {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- String antalspelare = JOptionPane.showInputDialog("Antal spelare?");
- String antalkast = JOptionPane.showInputDialog("Antal tärningskast?");
- String resultat = "";
- int spelare = Integer.parseInt(antalspelare);
- int kast = Integer.parseInt(antalkast);
- int raknare = 0;
- int raknare2 = 0;
- for (raknare=1; raknare <= spelare; raknare = raknare+1){
- for (raknare2=1; raknare2 <= kast ; raknare2 = raknare2+1){
- int tarning = (int)Math.ceil(Math.random()*6);
- resultat = resultat + tarning +" ";
- }
- JOptionPane.showMessageDialog(null, "Spelare: " + raknare + "\n" +
- "Antal kast: " + kast + "\nResultat: " + resultat + "");
- resultat = "";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement