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.
5 Respostas
+ 1
It is not rounding off the cost to nearest whole number (you can use round() function to achive that)
+ 1
it shows that round() is not declared in this scope
+ 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.
+ 1
Check this out👇
https://code.sololearn.com/c6NK3J1T3FtV/?ref=app
+ 1
thx