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; }
4 Réponses
+ 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;
+ 1
Brian okay, thanks a lot!!
0
The instructions require the output rounded up to the nearest dollar.
0
Brian how do I that? Round () ??