#C4736. Discount Calculator
Discount Calculator
Discount Calculator
You are given the original price of an item and a discount percentage. Your task is to calculate the final price after applying the discount. The calculation is based on the formula:
\(finalPrice = originalPrice - \frac{discountPercentage}{100} \times originalPrice\)
If the discount percentage is not within the interval \([0, 100]\), the program should output \(-1\) to indicate an invalid discount.
Read the two numbers from standard input and print the result to standard output.
inputFormat
The input consists of two space-separated floating-point numbers:
- originalPrice: The original price of the item before the discount.
- discountPercentage: The discount percentage to be applied.
Example: 100.0 20.0
outputFormat
Output a single number which is the final price after the discount is applied. If the discount percentage is invalid (i.e., less than 0 or greater than 100), output -1
.
100.0 20.0
80.0