Computer Science 121
Example using doubles.

// Application for a clerk in a store. It reads the price, calculates the tax and displays the total bill.

import java.io.*;
import java.text.*;

// Main class that declares a class that describes a store clerk and calls the methods.
public class Store
{
    public static void main (String [] args)
    {
        Clerk storeClerk = new Clerk ();
        storeClerk.getPrice ();
        storeClerk.calculateTax ();
        storeClerk.displayTotal ();
    } // method main
} // class Store

// Class that defines the work of a store clerk.
class Clerk
{
    private double price, tax, total;

    // Method that reads the price of a product from the keyboard.
    public void getPrice ()
    {
        System.out.print ("Enter the price: ");
        price = readDouble ();
    } // method getPrice

    // Method that calculates the tax.
    public void calculateTax ()
    {
        final double taxRate = 0.0825;
        tax = price * taxRate;
    } // method calculateTax

    // Method that calculates and then displays the total bill.
    public void displayTotal ()
    {
        total = tax + price;
        System.out.println ("The tax is $" + decimals (tax));
        System.out.println ("The total bill is $" + decimals (total));
    } // method displayTotal

    // Reads a double from the keyboard and returns it to the calling method.
    public double readDouble ()
    {
        double num = 0;
        try
        {
            BufferedReader stdin = new BufferedReader (new InputStreamReader (System.in));
            num = Double.valueOf (stdin.readLine ()).doubleValue ();
        }
        catch (IOException e) { System.out.println ("I/O error");}
        catch (NumberFormatException ex) { System.out.println ("Number format error.");}
        return num;
    } // method readDouble

    // Formats a double for string output with two decimal places.
    public String decimals (double num)
    {
        DecimalFormat decFor = new DecimalFormat ();
        decFor.setMaximumFractionDigits (2);
        decFor.setMinimumFractionDigits (2);
        return decFor.format (num);
    } // method decimals
} // class Clerk