diloentutospc

Calcular el cuadrado de un rango de numeros

Sep 28th, 2018
2,101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.59 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class RangoCuadrado {
  4.    
  5.     Scanner teclado = new Scanner(System.in);
  6.    
  7.     int inicio, fin, cuadrado;
  8.    
  9.     public void entradatos() {
  10.         System.out.print("Por favor ingrese el inicio del rango: ");
  11.         inicio = teclado.nextInt();
  12.         System.out.print("Por favor ingrese el fin del rango: ");
  13.         fin = teclado.nextInt();
  14.     }
  15.    
  16.     public void proceso() {
  17.         for (int i = inicio; i <= fin; i++) {
  18.             System.out.println(Math.pow(i, 2));
  19.         }
  20.     }
  21.  
  22.     public static void main(String[] args) {
  23.         RangoCuadrado fc = new RangoCuadrado();
  24.         fc.entradatos();
  25.         fc.proceso();
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment