Variables Only Hold Values

Code

    /// Name: Rachel Smith
    /// Period: 5
    /// Program Name: Variables Only Hold Values
    /// File Name: VariablesOnlyHoldValues.java
    /// Date Finished: 9/25/2015
    
    import java.util.Scanner;
    
    public class VariablesOnlyHoldValues {
        
        public static void main( String[] args ) {
            
            Scanner keyboard = new Scanner(System.in);
            double price, salesTax, total;
            /// without the "=0" the variable price has no value, so salesTax can't be calculated.
            /// once salesTax and total are defined after the initial question, there is no error when "=0" is removed.
            System.out.println( "How much is the purchase price? " );
            price = keyboard.nextDouble();
            
            salesTax = price*0.0825;
            total = price + salesTax;
            
            System.out.println( "Item price:\t" + price );
            System.out.println( "Sales tax:\t" + salesTax );
            System.out.println( "Total cost:\t" + total );
        }
    }
    

Picture of the output

Assignment 1