0

This is the paint cost question. I'm getting the first two test right but others are wrong. What is wrong in the code?

#include <iostream> using namespace std; int main() { int canvas = 40; int number; int paint ; float sum ; float tax ; float total ; cin >> number ; paint = number * 5 ; sum = paint + canvas ; tax = sum / 10; total = sum + tax ; cout << total ; return 0; }

26th May 2021, 5:18 AM
Kruti
Kruti - avatar
4 ответов
+ 1
To round upward there is a function called "ceil()" [ceiling] in the math library. #include <math.h> ... total = ceil(sum + tax); https://www.cplusplus.com/reference/cmath/ceil/ However, merely using ceil() is not sufficient. I found that I also had to cast the result to integer on output in order to pass the fifth test. cout << (int)total;
26th May 2021, 11:17 AM
Brian
Brian - avatar
+ 1
Brian okay, thanks a lot!!
26th May 2021, 3:55 PM
Kruti
Kruti - avatar
0
The instructions require the output rounded up to the nearest dollar.
26th May 2021, 5:45 AM
Brian
Brian - avatar
0
Brian how do I that? Round () ??
26th May 2021, 6:32 AM
Kruti
Kruti - avatar