0

wired result? (paint costs / code coach)

I was solving this easy problem (https://www.sololearn.com/coach/22?ref=app ), in the end, this was the result, three were true and two hidden were wrong why these two hidden wrong??, Can anyone help and explain to me that?. I have published the code and result as screenshots in my activity, please see them, thanks!.

20th Jul 2021, 6:07 PM
Eyad Al-Ahmar
Eyad Al-Ahmar - avatar
5 ответов
+ 2
You need to change the datatype of your input variable to avoid losing decimals. Also, output should be rounded. #include <iostream> #include <cmath> using namespace std; int main() { float n; cin>>n; cout<<int(round(40.0+n*5.0+(40.0+n*5.0)/10.0)); return 0; }
20th Jul 2021, 7:06 PM
Simba
Simba - avatar
+ 1
According to the task description, we're to ***round up*** the result.
20th Jul 2021, 6:10 PM
Lisa
Lisa - avatar
+ 1
Solved! Thank you Simba for your help (knowing that I'm still surprised it didn't accept my previous work)
20th Jul 2021, 8:45 PM
Eyad Al-Ahmar
Eyad Al-Ahmar - avatar
0
I already understood the describtion, I don't think there's a mistake, or lack of work...
20th Jul 2021, 6:15 PM
Eyad Al-Ahmar
Eyad Al-Ahmar - avatar
0
round up == ceil/ ceiling 1.1 --> 2
20th Jul 2021, 7:27 PM
Lisa
Lisa - avatar