Numeros Pseaudoaleatorios

Páginas: 10 (2253 palabras) Publicado: 24 de octubre de 2012
Generación de Números Pseudo aleatorios.

Objetivo: Realizar un programa en lenguaje Java donde introduzcas una semilla (numero aleatorio), y a partir de este, se generen una serie de número pseudo-aleatorios los cuales van desde el 0 al 1.
Métodos a utilizar:
1. Método del cuadrado medio
2. Método Congruencia Lineal
3. Método de la función “Random” de Java
Una vez generados,se elabore una gráfica donde se visualice la aleatoriedad de ellos.
Codigo en Java
import java.awt.BorderLayout;
import java.util.Random;
import javax.swing.JPanel;
import javax.swing.JFrame;
import java.awt.Dimension;
import javax.swing.JTextField;
import java.awt.Rectangle;
import javax.swing.ButtonGroup;
import javax.swing.DefaultListModel;
import javax.swing.JLabel;
importjavax.swing.JRadioButton;
import javax.swing.JList;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.table.TableColumn;
import javax.swing.JButton;
import java.awt.Panel;
import java.awt.GridBagLayout;
import java.awt.FlowLayout;
import java.awt.TextField;
import java.awt.image.BufferedImage;
import java.util.logging.Level;import java.util.logging.Logger;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartFrame;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.*;
import java.io.*;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import org.jfree.chart.ChartUtilities;
import org.jfree.data.category.DefaultCategoryDataset;
importorg.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
public class pseudo extends JFrame {

private static final long serialVersionUID = 1L;
private JPanel panel = null;
private JTextField semilla = null;
private JLabel jLabel = null;
private JLabel jLabel1 = null;
private DefaultListModel listam;
private JButton Generar = null;
public int opc;
public int r1;JRadioButton metodo1 = new JRadioButton("Yes" , true);
JRadioButton metodo2 = new JRadioButton("No" , false);
JRadioButton metodo3 = new JRadioButton("Maybe", false);

ButtonGroup bgroup = new ButtonGroup(); // @jve:decl-index=0:
private Panel panel2 = null;
private JLabel cuadrado = null;
private JLabel lineal = null;
private JLabel Rand = null;
private TextField resultado1= null;
private TextField resultado2 = null;
private JLabel jLabel11 = null;
private JLabel jLabel111 = null;
private TextField resultado3 = null;
private JLabel jLabel1111 = null;
private TextField resultado4 = null;
private JLabel jLabel11111 = null;
private TextField resultado5 = null;
private JLabel jLabel6 = null;
private TextField resultado6 = null;
private JLabeljLabel7 = null;
private TextField resultado7 = null;
private JLabel jLabel8 = null;
private TextField resultado8 = null;
private JLabel jLabel9 = null;
private JLabel jLabel10 = null;
private TextField resultado9 = null;
private TextField resultado10 = null;
/**
* This is the default constructor
*/
public pseudo() {
super();
initialize();
}

/**
* This methodinitializes this
*
* @return void
*/
private void initialize() {
metodo3.setBounds(new Rectangle(2, 53, 21, 21));
metodo2.setBounds(new Rectangle(4, 34, 21, 21));
metodo1.setBounds(new Rectangle(4, 14, 21, 21));
this.setSize(793, 362);
this.setContentPane(getPanel());
this.setTitle("Números-Pseudoaleatorios");
}

/**
* This method initializes panel
*
*@return javax.swing.JPanel
*/
private JPanel getPanel() {
if (panel == null) {



jLabel10 = new JLabel();
jLabel10.setBounds(new Rectangle(492, 238, 127, 26));
jLabel10.setText("Resultado 10");
jLabel9 = new JLabel();
jLabel9.setBounds(new Rectangle(492, 176, 126, 28));
jLabel9.setText("Resultado 9");
jLabel8 = new JLabel();
jLabel8.setBounds(new...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • El Numero E
  • Los numeros
  • Numero
  • EL NUMERO
  • Números
  • NUMEROS
  • numeros
  • Los Numeros

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS