The out expected to be 'The total meal cost is 13 dollars.' but it give 'The total meal cost is 12 dollars.'
#include <bits/stdc++.h> #include <iostream> #include <cmath> using namespace std; void solve(double meal_cost, int tip_percent, int tax_percent) { long double tip = (meal_cost*tip_percent)/100; long double tax = (meal_cost*tax_percent)/100; double totalcost = meal_cost+tip+tax; cout<< "The total meal cost is " << int(totalcost) << " dollars." <<endl; } int main() { double meal_cost; cin >> meal_cost; cin.ignore(numeric_limits<streamsize>::max(), '\n'); int tip_percent; cin >> tip_percent; cin.ignore(numeric_limits<streamsize>::max(), '\n'); int tax_percent; cin >> tax_percent; cin.ignore(numeric_limits<streamsize>::max(), '\n'); solve(meal_cost, tip_percent, tax_percent); return 0; } Input must be -: 10.25 17 5