+ 1

Please help!

Hey guys Please help I'm kinda still learning.. I could not solve the third and forth cases of this problem neither with python nor c++ Can anyone tell me what have I done wrong.. Thank you Here is my code in python: canvas = 40.00 color = 5.00 tax = 0.1 def cal(colors): total = colors * color + canvas taxes = total * tax print(int(taxes + total)) colors = int(input()) cal(colors) And in c++: #include <iostream> using namespace std; int calculate(int colors){ float canvas = 40.00; float color = 5.00; float tax = 0.1; int price = colors * color + canvas; int taxes = price * tax; return price + taxes; } int main() { int colors; cin >> colors; int total = calculate(colors); cout << total; return 0; } https://www.sololearn.com/coach/22?ref=app

11th Jul 2020, 8:03 PM
Mohammad Kikhia
Mohammad Kikhia - avatar
3 ответов
+ 2
if you check the description again in output format, notice "rounded up to the nearest whole number" in c++, for example float 0.2 casted to int it'll rounded down to 0. but the answer need tobe rounded up. here's the function you need http://www.cplusplus.com/reference/cmath/ceil/
11th Jul 2020, 8:16 PM
Taste
Taste - avatar
+ 2
//C++ code #include <iostream> #include <cmath> using namespace std; int main() { int colors; cin >> colors; double price = colors * 5 + 40; double taxes = price * 0.1; double total = price+taxes; int t = round(total); cout << t; return 0; }
12th Jul 2020, 12:10 AM
Armen Petrosyan
Armen Petrosyan - avatar
0
Taste i guess i should read the whole thing next time 😅 Thank alot bro :))
11th Jul 2020, 8:22 PM
Mohammad Kikhia
Mohammad Kikhia - avatar