joseleonweb

Untitled

Sep 21st, 2019
128
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. //Anem a llegir un enter entre 0 i 10.
  4. public class ValorFitat {
  5.     public static void main (String[] args) {
  6.         Scanner lector = new Scanner(System.in);
  7.         int valorUsuari = 0;
  8.         do {
  9.             //PAS 1 i 2: Com a mínim, segur que es pregunta un cop.
  10.             System.out.print("Introdueix un valor enter entre 0 i 10: ");
  11.             valorUsuari = lector.nextInt();
  12.             lector.nextLine();
  13.             //PAS 3: Només té sentit avaluar si ’valor’ és vàlid un cop s’ha llegit.
  14.         } while ((valorUsuari < 0)||(valorUsuari > 10));
  15.         //PAS 4: Tot correcte
  16.         System.out.println("Dada correcta. Has escrit " + valorUsuari);
  17.     }
  18. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×