# Day 2: Operators(HackerRank – 30 Days of Code)

Given the meal price (base cost of a meal), tip percent (the percentage of the meal price being added as a 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. Round the result to the nearest integer.

Input Format:

There are 3 lines of numeric input:
The first line has a double,mealcost  (the cost of the meal before tax and tip).
The second line has an integer,tippercent  (the percentage of mealcost being added as tip).
The third line has an integer, taxpercent (the percentage of mealcost being added as tax).

Solution:

1.Javascript:

``````function solve(meal_cost, tip_percent, tax_percent) {
// Write your code here
const tip = meal_cost*(tip_percent*.01);
const tax = meal_cost*(tax_percent*.01);
console.log(Math.round(meal_cost+tax+tip));
}

function main() {

solve(meal_cost, tip_percent, tax_percent);
}``````

2.Java:

``````class Result {

/*
* Complete the 'solve' function below.
*
* The function accepts following parameters:
*  1. DOUBLE meal_cost
*  2. INTEGER tip_percent
*  3. INTEGER tax_percent
*/

public static void solve(double meal_cost, int tip_percent, int tax_percent) {
// Write your code here
double tip = meal_cost*(tip_percent*.01);
double tax = meal_cost*(tax_percent*.01);
System.out.println(Math.round(meal_cost+tax+tip));
}

}

public class Solution {
public static void main(String[] args) throws IOException {