Hackerrank | 30 days of code | Day 2-Solution in c++| Operators-hackerrank-Solution-in-c++


Hackerrank | 30 days of code | Day 2-Solution in c++| Operators-hackerrank-Solution-in-c++

Hackerrank Solution 30-days-of-code
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; }

Post a Comment

0 Comments