The answer is given below:
Here is the complete program.
import java.util.Scanner;
public 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) );
}
}
Is the logic of the program is correct?
The expression (price+tax) in the last statement
sometimes adds zero to price.
This is fine.
Adding zero does not change the result.
The user buys a shirt for $100 What will be printed on the monitor?