SHARE
TWEET

Untitled

a guest May 20th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. class BoiaDeh {
  4.     public static void main(String args[]) {
  5.         Scanner obj = new Scanner(System.in);
  6.         static string s1 = "Pisa Merda";
  7.         static string s2 = "Winter is coming";
  8.         int n;
  9.  
  10.         System.out.println("Quante volte vuoi stampare " + s1 + "?");
  11.         n = obj.nextInt();
  12.         Foo(n, s1);
  13.  
  14.         System.out.println("Quante volte vuoi stampare " + s2 + "?");
  15.         n = obj.nextInt();
  16.         Foo(n, s2);
  17.  
  18.         //stampano "Pisa è bellissima"
  19.         Foo(-129, s1);
  20.         Foo(9999, s2);
  21.        
  22.         //Stampa 10 volte "dieci"
  23.         Foo(10, "dieci")
  24.     }
  25.  
  26.     //Stampa n volte s se n è compreso fra 1 e MAX_TIMES, stampa "Pisa è bellissima!" altrimenti
  27.     private void Foo(int n, string s) {
  28.         static int MAX_TIMES = 1000;
  29.  
  30.         if (n > 0 && n < MAX_TIMES)
  31.             for (int i=0; i<n; i++)
  32.                 System.out.println(s);
  33.         else
  34.             System.out.println("Pisa è bellissima!");
  35.     }
  36. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top