Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- /*
- * 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.
- */
- /**
- *
- * @author Uriel
- */
- public class MetodosCuadrados {
- public static void main(String[] args) {
- Scanner xr = new Scanner(System.in);
- int n;
- int semilla;
- System.out.println("Iteracciones");
- n = xr.nextInt();
- System.out.println("Semilla");
- semilla = xr.nextInt();
- for (int i = 0; i < n; i++) {
- int cuadrado = semilla*semilla;
- String cuad = cuadrado+"";
- if(cuad.length()%2 != 0){
- cuad = "0"+cuad;
- }
- String centro = cuad.substring( ((cuad.length()/2)-2), (((cuad.length()/2)-2)+4));
- double uniforme = Double.parseDouble(centro) / 10000;
- System.out.println("Iteraccion: "+(i+1)+" Numero "+semilla+" Cuadrado "+cuad+" Centro "+centro+" "+" Uniforme "+uniforme);
- semilla = Integer.parseInt(centro);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement