JAVA random basic dice

  1. package firstjava;
  2.  
  3. public class casino {
  4.  
  5.     public static void main(String[] args) {
  6.         int i,j;
  7.         int iDice1,iDice2,iSum;
  8.         iDice1 = (int)(Math.random() * 5+1);
  9.         iDice2 = (int)(Math.random() * 5+1);
  10.         System.out.println( iDice1 + "  " + iDice2 );
  11.         iSum = iDice1 + iDice2;
  12.         System.out.println( "\n" + iSum );
  13.     }
  14.  
  15. }

留言

這個網誌中的熱門文章

Codeforces --- string task

Uva 674 ---- coin change

codeforces 271A --- beautiful year