Advertisement
joseleonweb

Untitled

Aug 23rd, 2019
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.57 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class MostraInterval {
  4.  
  5.   public static void main (String[] args) {
  6.     Scanner lector = new Scanner(System.in);
  7.  
  8.     System.out.print("Quin és el valor de n1? ");
  9.     int n1 = lector.nextInt();
  10.     lector.nextLine();
  11.  
  12.     System.out.print("Quin és el valor de n2 (més gran que n1)? ");
  13.     int n2 = lector.nextInt();
  14.     lector.nextLine();
  15.  
  16.     if (n1 < n2) {
  17.       for (int i = n1; i <= n2; i++) {
  18.         System.out.println(i);
  19.       }
  20.     } else {
  21.       System.out.println("n2 no és més gran que n1!");
  22.     }
  23.   }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement