Answer:

The answer is given below:

Adding in a Zero

Here is the complete program.

import java.util.Scanner;
class TaxProgram
{
  public static void main (String[] args)
  {
    final double taxRate = 0.05;
    Scanner scan = new Scanner( System.in );
    double price;
    double tax ;

    System.out.println("Enter the price:");
    price  = scan.nextDouble();     

    if ( price >= 100.0  )
      tax = price * taxRate;   
    else
      tax = 0.0;

    System.out.println("Item cost: " + price + 
        " Tax: " + tax + " Total: " + (price+tax) );    
  }
}

You might wonder if the logic of the program is correct because the expression (price+tax) in the last statement will sometimes add zero to price. This is fine. Adding zero does not change the result.

QUESTION 13:

The user buys a shirt for $100 What will be printed on the monitor?