Code Coach - Kaleidoscopes
I can't seem to figure out why my coding is failing on the last two tests :( It passes the first three by correctly rounding the number to two decimal places, but the last two tests are hidden and do not show the input or output. Here is what I have (I've been trying to round the number different ways and commenting them out): #include <iostream> #include <iomanip> using namespace std; float round(float total) { float value = (int)(total * 100 + .5); return (float)value / 100; } const float scopeCost = 5.00; const float scopeDiscount = 0.10; const float scopeTax = 0.07; int main() { int scopeBuy; float total; cin >> scopeBuy; total = scopeBuy * scopeCost; if(scopeBuy > 1){ total = total - (scopeDiscount * total); }; total = total + (scopeTax * total); //cout << std::fixed << std::setprecision(2) >> total; printf("%.2f", round(total)); //cout << round(total); return 0; }