package variables;

public class Constants {
    /*
     * Constants are declared outside the main() method so they
     * can be used everywhere in the program (this will become
     * important after you learn to write your own methods).
     * 
     * For now, our constants will be defined with the "public" modifier.
     * Constants in a Main Class must be defined as "static".
     * Constants must be declared with the "final" modifier:
     * - this means the constant's value is not allowed to be changed
     * while the program runs
     * Constants must have a data type and must be initialized.
     * Once initialized, a constant's value may not change during
     * run time.
     * Constant identifiers have all upper-case letters and use
     * the underscore _ to separate words.
     */
    public static final double HST_RATE = .13;

    public static void main(String[] args) {

        double price = 19.99; // item price
        int quantity = 20; // # of item to buy

        // not allowed because HST_RATE is final:
        // HST_RATE = .1;

        // calculate totals and taxes
        double subTotal = price * quantity;
        double taxAmount = subTotal * HST_RATE;
        double finalTotal = subTotal + taxAmount;

        // display the bill/invoice
        System.out.printf("Sub Total: $%.2f\nTax: $%.2f\nTotal: $%.2f\n",
                subTotal, taxAmount, finalTotal);
    }
}
