Round-off problem in paints cost challenge | SoloLearn: Learn to code for FREE!

+2

Round-off problem in paints cost challenge

format : (40 + paintsNum * 5) * (100 + tax rate)/100 100 + tax rate = 100 + 9 = 109 In test case 1 : (40 + 2 * 5) * 109 / 100 = 54.5 ~ 55 Correct! In test case 2 : (40 + 20 * 5) * 109 / 100 = 152.6 ~ 153 But its output showing 154. Tell me how ?

7/4/2020 2:17:32 AM

Akash Kumar

3 Answers

New Answer

+5

Akash Kumar The tax rates in paint costs challenge is 10% not 9% So, you must use 10 instead 9 / 100

+5

+2

𝐊𝐢𝐢𝐛𝐨 𝐆𝐡𝐚𝐲𝐚𝐥 Here it is #include <iostream> using namespace std; int main() { unsigned int paints = 0; cin >> paints; unsigned int cost = (40 + 5 * paints); double tax = (double) cost * 9 / 100; unsigned int temp = tax; if ((double) (tax - temp)) cout << cost + temp + 1; else cout << cost + temp; return 0; }