/**
 * This little program prints some nice sentences on the screen
 */
public class HelloWorld {
    /**
     * main function
     */
    public static void main(String[] args) {
	int x = 42;  // declaration and initialization
	
	x = sommaQuarantadue(x + 2); // call of function: pass by value
	
	double pi = 3.14; 

	pi = pi * 2; // compute expression

	int n = 17;

	double y = pi + x;

	// string concatenation
	String s = "il numero e' " + x + ", 2pi vale circa " + pi;

	// boolean values: true or false
	boolean verbose = true; 
	
	// if statement: conditional execution
	if (verbose) {
	    System.out.println(s);
	    System.out.println("5! = " + factorial(5));
	} 
    }

    /**
     * Example of function
     * a function is a black box!
     */
    static int sommaQuarantadue(int n) {
	n += 42;
	return n;
    }

    /**
     * Example of recursive function
     */
    static int factorial(int n) {
	if (n == 0) {
	    return 1;
	} else {
	    return n * factorial(n-1);
	}
    }
}