We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
'usestrict';process.stdin.resume();process.stdin.setEncoding('utf-8');letinputString='';letcurrentLine=0;process.stdin.on('data',function(inputStdin){inputString+=inputStdin;});process.stdin.on('end',function(){inputString=inputString.split('\n');main();});functionreadLine(){returninputString[currentLine++];}/* * Complete the 'solve' function below. * * The function accepts following parameters: * 1. DOUBLE meal_cost * 2. INTEGER tip_percent * 3. INTEGER tax_percent */functionsolve(meal_cost,tip_percent,tax_percent){// Calculate tip amountconsttip=meal_cost*(tip_percent/100);// Calculate tax amountconsttax=meal_cost*(tax_percent/100);// Calculate total costconsttotal_cost=meal_cost+tip+tax;// Round the total cost to the nearest integerconstrounded_cost=Math.round(total_cost);console.log(rounded_cost);}functionmain(){constmeal_cost=parseFloat(readLine().trim());consttip_percent=parseInt(readLine().trim(),10);consttax_percent=parseInt(readLine().trim(),10);solve(meal_cost,tip_percent,tax_percent);}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Day 2: Operators
You are viewing a single comment's thread. Return to all comments →
My Solution JavaScript