Hello **Programmers/Coders,** Today we are going to share ** solutions of Programming problems of 30 Days Of Code, HackerRank**. At Each Problem with Successful submission with

**all Test Cases Passed,**you will get an score or marks. And after solving maximum problems, you will be getting stars. This will highlight your profile to the recruiters.

In this post, you will find the solution for **Day 2: Operators** **in Java-HackerRank Problem**. We are providing the **correct and tested solutions** of coding problems present on **HackerRank**. If you are not able to solve any problem, then you can take help from our Blog/website.

Use “Ctrl+F” To Find Any Questions Answer. & For Mobile User, You Just Need To Click On Three dots In Your Browser & You Will Get A “Find” Option There. Use These Option to Get Any Random Questions Answer.

** Link for the Problem** – Day 2: Operators – Hacker Rank Solution

Day 2: Operators – Hacker Rank Solution

**Problem:**

**Objective**

In this challenge, you will work with arithmetic operators. Check out the Tutorial tab for learning materials and an instructional video.

**Task**

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*. Round the result to the nearest integer.

**Example**

A tip of 15% * 100 = 15, and the taxes are 8% * 100 = 8. Print the value and return from the function.

**Function Description**

Complete the *solve* function in the editor below.

*solve* has the following parameters:

*int meal_cost:*the cost of food before tip and tax*int tip_percent:*the tip percentage*int tax_percent:*the tax percentage

Returns The function returns nothing. Print the calculated value, rounded to the nearest integer.

**Note:** Be sure to use precise values for your calculations, or you may end up with an incorrectly rounded result.

**Input Format**

There are lines of numeric input:

The first line has a double, (the cost of the meal before tax and tip).

The second line has an integer, (the percentage of being added as tip).

The third line has an integer, (the percentage of being added as tax).

**Sample Input**

12.00 20 8

**Sample Output**

15

**Explanation**

Given:

, ,

Calculations:

We round to the nearest integer and print the result, .

Day 2: Operators – Hacker Rank Solution

import java.util.Scanner; /** * @author Techno-RJ * */ public class Day2Operators { public static void main(String[] args) { Scanner scan = new Scanner(System.in); double mealCost = scan.nextDouble(); // original meal price int tipPercent = scan.nextInt(); // tip percentage int taxPercent = scan.nextInt(); // tax percentage scan.close(); // Write your calculation code here. double tC = mealCost + (mealCost * tipPercent) / 100 + (mealCost * taxPercent) / 100; // cast the result of the rounding operation to an int and save it as totalCost int totalCost = (int) Math.round(tC); System.out.println("The total meal cost is " + totalCost + " dollars."); // Print your result } }