Advertisement
urksiful

Centros al cuadrado RANDOM Gen

Aug 31st, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.29 KB | None | 0 0
  1.  
  2. import java.util.Scanner;
  3.  
  4. /*
  5.  * To change this license header, choose License Headers in Project Properties.
  6.  * To change this template file, choose Tools | Templates
  7.  * and open the template in the editor.
  8.  */
  9.  
  10. /**
  11.  *
  12.  * @author Uriel
  13.  */
  14. public class MetodosCuadrados {
  15.    
  16.     public static void main(String[] args) {
  17.         Scanner xr = new Scanner(System.in);
  18.         int n;
  19.         int semilla;
  20.        
  21.         System.out.println("Iteracciones");
  22.        
  23.         n = xr.nextInt();
  24.        
  25.         System.out.println("Semilla");
  26.         semilla = xr.nextInt();
  27.        
  28.         for (int i = 0; i < n; i++) {
  29.            
  30.             int cuadrado = semilla*semilla;
  31.             String cuad = cuadrado+"";
  32.            
  33.             if(cuad.length()%2 != 0){
  34.                 cuad = "0"+cuad;
  35.             }
  36.          
  37.             String centro = cuad.substring( ((cuad.length()/2)-2), (((cuad.length()/2)-2)+4));
  38.            
  39.             double uniforme = Double.parseDouble(centro) / 10000;
  40.            
  41.            
  42.             System.out.println("Iteraccion: "+(i+1)+" Numero "+semilla+"  Cuadrado  "+cuad+"  Centro "+centro+"  "+" Uniforme  "+uniforme);
  43.            
  44.             semilla = Integer.parseInt(centro);
  45.         }
  46.        
  47.        
  48.     }
  49.    
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement