Just started my first unit in Java and my lecturer has set some code with logical errors in it. I think I have found them all bar one. the problem that I am having is that when I run this script it should calculate the Tax for the dollar amount but the tax stays at 55c whether it a $1 or $10 or even $100. It’s always 55c Tax.
//This program calculates the total price which includes sales tax
import java.util.Scanner;
public class SalesTax
{
public static void main(String[] args)
{
//identifier declarations
final double TAX_RATE = 0.55;
double price;
double tax;
double total;
String item;
//create a Scanner object to read from the keyboard
Scanner keyboard = new Scanner(System.in);
//display prompts and get input
System.out.print("Item description: ");
item = keyboard.nextLine();
System.out.print("Item price: $");
price = keyboard.nextDouble();
//calculations
tax = TAX_RATE;
total = price + tax;
//display results
System.out.print("item $");
System.out.println(price);
System.out.print("Tax $");
System.out.println(tax);
System.out.print("Total $");
System.out.println(total);
}
}