CSharp - Write program to Create Tax Calculator

Requirements

Read the price a customer pays for a product.

Then calculate the price without Tax and also the Tax itself.

Hint

If the Tax rate is 21 percent, divide the customer price by 1.21 to get the price without the Tax.

Demo

using System;
class Program//  w  w w .j  a v a 2 s . c  om
{
    static void Main(string[] args)
    {
        // Inputs 
        Console.Write("Enter customer price of a product: ");
        string inputPrice = Console.ReadLine();
        double customerPrice = Convert.ToDouble(inputPrice);

        Console.Write("Enter Tax rate in %: ");
        string inputTaxRate = Console.ReadLine();
        double taxRate = Convert.ToDouble(inputTaxRate);

        // Calculations 
        double divisor = 1 + taxRate / 100.0;
        double calculatedPriceWithoutTax = customerPrice / divisor;
        double priceWithoutTax = Math.Round(calculatedPriceWithoutTax, 2);
        double tax = customerPrice - priceWithoutTax;

        // Outputs 
        Console.WriteLine("Price without Tax: " + priceWithoutTax.ToString("N2"));
        Console.WriteLine("Tax: " + tax.ToString("N2"));
    }
}

Result