luistavares

Gerando Números Aleatórios em Java

Mar 1st, 2013
97
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import javax.swing.JOptionPane;
  2.  
  3. public class MegaSena {
  4.    
  5.     public static void main(String[] args) {
  6.         int a, b, c, d, e, f;
  7.         a = (int) (Math.random() * 61);
  8.         b = (int) (Math.random() * 61);
  9.         c = (int) (Math.random() * 61);
  10.         d = (int) (Math.random() * 61);
  11.         e = (int) (Math.random() * 61);
  12.         f = (int) (Math.random() * 61);
  13.        
  14.         String texto = "Sugestão Mega-Sena: \n" + a + "-" + b + "-" + c + "-" + d + "-" + e + "-" + f;
  15.        
  16.         JOptionPane.showMessageDialog(null, texto, "Mega-Sena", JOptionPane.INFORMATION_MESSAGE);                              
  17.     }
  18. }
RAW Paste Data