0

What's wrong with my code?

I'm doing a "Paint costs" challenge and I did that code: #include <iostream> using namespace std; int main() { int cost; cin >> cost; cost = cost * 5 + 40; int tax = cost / 10; cost += tax; cout << cost; return 0; } After testng it, cases 3, 5 failed and I dont know what to do because after trying to show test case, I get message that this test case is hidden. Help.

21st Feb 2020, 2:06 PM
Grzesiek Sikorski
Grzesiek Sikorski - avatar
5 Respostas
+ 1
It is not rounding off the cost to nearest whole number (you can use round() function to achive that)
21st Feb 2020, 2:10 PM
Arsenic
Arsenic - avatar
+ 1
it shows that round() is not declared in this scope
21st Feb 2020, 2:14 PM
Grzesiek Sikorski
Grzesiek Sikorski - avatar
+ 1
1. When buying an uneven amount, the tax will include a floating point value, which will be cut off by using int. 2. The task states to round up, while round() rounds either up or down, depending on the number. Use std::ceil() instead: https://en.cppreference.com/w/cpp/numeric/math/ceil If you do, do not forget to include the <cmath> library beforehand.
21st Feb 2020, 2:49 PM
Shadow
Shadow - avatar
21st Feb 2020, 3:08 PM
Arsenic
Arsenic - avatar
+ 1
thx
22nd Feb 2020, 6:50 AM
Grzesiek Sikorski
Grzesiek Sikorski - avatar