0

Solving code coach.On input 3 my answer is 14.55 but actual answer is 14.45.

You sell souvenir kaleidoscopes at a gift shop, and if a customer buys more than one, they get a 10% discount on all of them! Given the total number of kaleidoscopes that a customer buys, let them know what their total will be. Tax is 7%. All of your kaleidoscopes cost the same amount, 5.00. Task: Take the number of kaleidoscopes that a customer buys and output their total cost including tax and any discounts. Input Format: An integer value that represents the number of kaleidoscopes that a customer orders. Output Format: A number that represents the total purchase price to two decimal places. Sample Input: 4 Sample Output: 19.26 https://code.sololearn.com/clRALcKITDKU/?ref=app

14th Aug 2023, 2:57 AM
Iqra Fatima (Student)
Iqra Fatima (Student) - avatar
1 ответ
+ 2
Iqra Fatima (Student) Most of your code is correct, aside from a few errors: 1. Use `double` instead of `float` for applications involving floating-point computations where memory isn't a concern. It literally has twice the precision of decimal digits, resulting in fewer rounding errors during final output. 2. `tax` should be calculated AFTER taking the discount into account. Try adding this in the first `if` statement, before calculating `TotalD`: tax = (7.0/100.0)*(costPrice - discount);
14th Aug 2023, 4:31 AM
Mozzy
Mozzy - avatar