thats a nice code but it failed in test case 3 because instead of converting value to int we should use round function it will give you nearby value of double value, using this will be better :)
using namespace std;
// Complete the solve function below.
void solve(double meal_cost, double tip_percent, double tax_percent) {
double total_cost; total_cost = meal_cost + meal_cost * tip_percent/100 + meal_cost * tax_percent/100; cout.precision(10); cout <<round(total_cost) <<endl;
}
int main() { double meal_cost; cin >> meal_cost; cin.ignore(numeric_limits::max(), '\n');
double tip_percent; cin >> tip_percent; cin.ignore(numeric_limits<streamsize>::max(), '\n'); double tax_percent; cin >> tax_percent; cin.ignore(numeric_limits<streamsize>::max(), '\n'); solve(meal_cost, tip_percent, tax_percent); return 0;
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
thats a nice code but it failed in test case 3 because instead of converting value to int we should use round function it will give you nearby value of double value, using this will be better :)
include
using namespace std;
// Complete the solve function below.
void solve(double meal_cost, double tip_percent, double tax_percent) {
}
int main()
{
double meal_cost;
cin >> meal_cost;
cin.ignore(numeric_limits::max(), '\n');
}