#K62237. Calculate Total Cost for Book Purchases
Calculate Total Cost for Book Purchases
Calculate Total Cost for Book Purchases
You are given the number of books purchased and whether the purchase was made on a weekend. The pricing scheme is defined as follows:
- If \(1 \leq n \leq 3\): each book costs $12.
- If \(4 \leq n \leq 6\): each book costs $10.
- If \(n \geq 7\): each book costs $8.
If the purchase is made on a weekend, a discount of 10% is applied to the total cost. In mathematical terms, if \(n\) is the number of books and the price per book is \(p\), then the total cost \(C\) is:
\[ C = \begin{cases} 0 & \text{if } n \leq 0,\\[1mm] n \times p & \text{if not weekend},\\[1mm] 0.9 \times n \times p & \text{if weekend.} \end{cases} \]Your task is to implement a solution that reads the number of books and a boolean flag indicating if it is a weekend, and then outputs the calculated total cost based on the above conditions.
inputFormat
The input is provided via standard input (stdin) and consists of two lines:
- The first line contains an integer representing the number of books purchased.
- The second line contains a string (True or False) indicating whether the purchase was made on a weekend.
outputFormat
The output should be printed to standard output (stdout) and is the total cost after applying the pricing scheme and any weekend discount. If the computed cost is a whole number, output it as an integer; otherwise, output the decimal value.
## sample1
False
12
</p>