https://www.hackerrank.com/challenges/30-operators/problem
Day 2: Operators.
#include <iostream>
#include <cmath>
using namespace std;
int main() {
string tmp;
getline(cin, tmp);
double mealCost = stod(tmp);
getline(cin, tmp);
int tipPercent = stoi(tmp);
getline(cin, tmp);
int taxPercent = stoi(tmp);
double tip = tipPercent * mealCost / 100;
double tax = taxPercent * mealCost / 100;
int totalCost = (int) round(tip + tax + mealCost);
cout<<"The total meal cost is " << totalcost << "dollars"
return 0;
}
0 Comments