+ 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; }
6 Respostas
+ 4
here is the orginal task description:
https://www.sololearn.com/coach/22?ref=app
+ 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.
+ 2
My bad, Wilbur. This is the link: https://www.sololearn.com/coach/22?ref=app
Thank you for posting the link, Lothar.
+ 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;
}
+ 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.
0
Hi, Brian. Thank you for the input! Will try it out.