A store is calculating the final price of a product. You have the following variables:
The base price is $100;
The tax rate is 8%;
And there's a $10 discount.
Can you reorder the lines of code to correctly calculate and print the final price?
A store is calculating the final price of a product. You have the following variables:
The base price is $100;
The tax rate is 8%;
And there's a $10 discount.
Can you reorder the lines of code to correctly calculate and print the final price?
double taxAmount = basePrice * (taxRate / 100);
double basePrice = 100.0, taxRate = 8.0, discountAmount = 10.0;
double finalPrice = basePrice + taxAmount - discountAmount;
}
}
public static void main(String[] args) {
System.out.printf("Final price: $%.2f\n", finalPrice);
public class ProductPriceCalculator {
Create a free account to access the full topic