/*Copyright ElohimTov LLC*/ /* //Name: ElohimTov Solve Code - Operators - Java Solution //Problem: HackerRank - 30 Days of Code - Operators //Current File: ElohimTovSolve_Operators.(java).txt //Compile-able File: ElohimTovSolve_Operators.java //Date: 02/12/2019 //Tale: ElohimTov Solve's Solution to HackerRank.com's // Operators problem, in Java programming language. // Problem link at https://elohimtov.com/elohimtov.info. */ import java.io.*; import java.math.*; import java.security.*; import java.text.*; import java.util.*; import java.util.concurrent.*; import java.util.regex.*; public class Solution { public static final int HUNDRED = 100; // Complete the solve function below. static void solve(double meal_cost, int tip_percent, int tax_percent) { double tip_amount = (meal_cost * tip_percent) / HUNDRED; double tax_amount = (meal_cost * tax_percent) / HUNDRED; double total_cost = meal_cost + tip_amount + tax_amount; int rounded_cost = (int)Math.round(total_cost); System.out.println(rounded_cost); }//ends function solve(...) private static final Scanner scanner = new Scanner(System.in); /* //CREDIT: The following main() function was provided by HackerRank.com */ public static void main(String[] args) { double meal_cost = scanner.nextDouble(); scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?"); int tip_percent = scanner.nextInt(); scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?"); int tax_percent = scanner.nextInt(); scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?"); solve(meal_cost, tip_percent, tax_percent); scanner.close(); }//ends function main(String[] args) }//ends class Solution /*Copyright ElohimTov LLC*/