diloentutospc

Figura mayor y menor que - Java

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