The code is below and the problem I am having is the numbers after the decimal won't add together for the total I am teaching myself java through liang's 10th edition book and I took one of the sample programs further than what was shown. The one in the book only shows the tax amount I simply wanted to make it so that the purchase amount and the tax amount would add together
package javalearning;
import java.util.Scanner;
public class FindingTax {
public static void main(String[] args){
Scanner input = new Scanner(System.in);
System.out.print("Enter Purchase amount: ");
double purchaseAmount = input.nextDouble();
double taxAmount = purchaseAmount * 0.0825;
System.out.println("Sales tax is $" + (int)(taxAmount * 100) /
100.0);
double taxTotal =(int) ((taxAmount * 100) / 100.0);
double TotalAmount = ((double)(taxTotal * 1.00) + purchaseAmount);
System.out.println("The total amount to pay is:" + TotalAmount);
}
}
This is the result
run:
Enter Purchase amount: 125.25
Sales tax is $ 10.33
The total amount to pay is: 135.25
BUILD SUCCESSFUL (total time: 5 seconds)
Any and all help is very appreciated.