+ 1

Test Case #5 Failed. Help.

#include <iostream> #include <math.h> using namespace std; //Paint Cost int main() { int qty; const double paint=5.00, cb=40.00, tax=0.10; double price, stax, total; cin>>qty; price = (qty * paint) + cb; stax = price * tax; total = price + stax; cout<<round(total); return 0; }

9th Jun 2024, 3:50 AM
Pat
6 Answers
+ 4
here is the orginal task description: https://www.sololearn.com/coach/22?ref=app
9th Jun 2024, 8:12 PM
Lothar
Lothar - avatar
+ 3
Pat, check the output requirement carefully. It says: "A number that represents the cost of your purchase rounded up to the nearest whole number." The total needs to be rounded up, not just rounded. You can use the ceil() function for that. And then be certain to cast it as an (int) for the output.
9th Jun 2024, 8:08 AM
Brian
Brian - avatar
+ 2
My bad, Wilbur. This is the link: https://www.sololearn.com/coach/22?ref=app Thank you for posting the link, Lothar.
10th Jun 2024, 3:55 AM
Pat
+ 2
Hi again, Brian. I did tweak the code based on your input, and it definitely helped solved the Paint Cost challenge. Thank you! Below is the revised code: #include <iostream> #include <cmath> using namespace std; int main() { int qty, total; const double paint=5.00, cb=40.00, tax=0.10; double price, stax; cin>>qty; price = (qty * paint) + cb; stax = price * tax; total = ceil(price + stax); cout<<total; return 0; }
10th Jun 2024, 4:08 AM
Pat
+ 1
“Test case #5” could be anything. You need to link to the lesson or at least say what the code is supposed to do.
9th Jun 2024, 5:00 AM
Wilbur Jaywright
Wilbur Jaywright - avatar
0
Hi, Brian. Thank you for the input! Will try it out.
10th Jun 2024, 3:56 AM
Pat