 # Day 2: Operators - 30 Days of Code HackerRank

Given the meal price (base cost of a meal), tip percent (the percentage of the meal price being added as tip), and tax percent (the percentage of the meal price being added as tax) for a meal, find and print the meal's total cost. Operators hackerrank solution in c++(cpp)

#include <bits/stdc++.h>

using namespace std;

// Complete the solve function below.

void solve(double meal_cost, int tip_percent, int tax_percent) {

int total_cost;
total_cost =  meal_cost + meal_cost * tip_percent/100 + meal_cost * tax_percent/100;
cout << total_cost <<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;
}


Operators hackerrank solution in Python

import math
import os
import random
import re
import sys

# Complete the solve function below.
def solve(meal_cost, tip_percent, tax_percent):

total_cost =  meal_cost + meal_cost * tip_percent/100 + meal_cost * tax_percent/100
print(round(total_cost))

if __name__ == '__main__':
meal_cost = float(input())

tip_percent = int(input())

tax_percent = int(input())

solve(meal_cost, tip_percent, tax_percent)



Operators hackerrank solution in JavaScript

// Complete the solve function below.
function solve(meal_cost, tip_percent, tax_percent) {

let total_cost;
total_cost =  meal_cost + meal_cost * tip_percent/100 + meal_cost * tax_percent/100;
console.log(Math.round(total_cost));
}

function main() {   