Posts

Showing posts from June, 2024

Product calculation

 import java.text.DecimalFormat; // Product excluding tax class class ProductExcludingTax {     private String productName;     private int quantity;     private double price;     private double taxRate; // Tax rate as a decimal (e.g., 0.1 for 10% tax)     // Constructor     public ProductExcludingTax(String productName, int quantity, double price, double taxRate) {         this.productName = productName;         this.quantity = quantity;         this.price = price;         this.taxRate = taxRate;     }     // Calculate total amount including tax     public double calculateTotalAmount() {         double totalAmount = quantity * price;         double taxAmount = totalAmount * taxRate;         return totalAmount + taxAmount;     }     // ...