package demo2;

public class VariableDemo2 {

    public static void main(String[] args) {

        /*
         * Quick summary of types:
         * 
         * Strings are actually objects in Java. String is a class, and
         * a string variable is a String object.
         * 
         * Everything else is a p͟r͟i͟m͟i͟t͟i͟v͟e type (just plain data, not
         * objects that are based on classes). In the next lesson, you'll
         * see that objects and primtives are stored in memory differently.
         * - Integers (byte, short, int, long) are for whole numbers (no
         * decimal/fractional portion)
         * - Floating points (float, double) are for floating point numbers
         * (numbers with a decimal)
         * There are also the primitive types boolean and char, but we'll
         * talk about those later.
         */

        // Let's try more than one variable:
        String thing = "Java"; // a thing
        int x = 2, // value for x
            y = 5; // value for y
        double price = 10.5; // price of thing

        /*
         * It's acceptable to declare more than one variable in the
         * same statement as long as they are of the same type (in this
         * case, both x and y are "int" variables). However, note the
         * indentation and spacing - this makes the code more readable
         * and makes it easy to document each variable if necessary.
         */

        // when you use + (concatenate) with a string on one side, it
        // concatenates the two values

        // string + int? it's casting x into a String first, not changing 
        // the operation (java is strongly typed)
        System.out.println(thing + x);  
        System.out.println(x + y);

        /*
         * NOTE:
         * See how we always put a space around operators? That's
         * an industry standard in Java and it makes your code
         * easier to read.
         */

        // System.out.println(thing + x + y); // wait, what??
        // how do you make x+y evaluate before the concatenation operation?

        /*
         * Solution:
         * System.out.println(thing + (x + y));
         */

        System.out.println(y / x); // does this output look right to you?
        /*
         * When both operands are integers, the result is always an integer.
         * (this is called INTEGER DIVISION)
         * To get a floating point result, one or both operands
         * has to be a floating point number. Try each of these:
         */
        // System.out.println(5 / 2.0);
        // System.out.println(5.0 / 2);
        // System.out.println(5.0 / 2.0);

        System.out.println(thing + " is $" + price);

        // one of these is invalid: why?
        // explain the problem to me like I'm 5 years old
        // int sum1 = x + y;
        // int sum2 = x + y + price;
        // double product = x * price;

        // what's wrong here?
        // System.out.println(Price);
    }
}
