Skip to content

Instantly share code, notes, and snippets.

@alwaisy
Created June 20, 2022 17:16
Show Gist options
  • Save alwaisy/95cde58d6ed46dc17b055ac2997805ec to your computer and use it in GitHub Desktop.
Save alwaisy/95cde58d6ed46dc17b055ac2997805ec to your computer and use it in GitHub Desktop.
// all test 0 => failed, test [1,2,3] => passed
'use strict';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', function(inputStdin) {
inputString += inputStdin;
});
process.stdin.on('end', function() {
inputString = inputString.split('\n');
main();
});
function readLine() {
return inputString[currentLine++];
}
/*
* Complete the 'solve' function below.
*
* The function accepts following parameters:
* 1. DOUBLE meal_cost
* 2. INTEGER tip_percent
* 3. INTEGER tax_percent
*/
function solve(meal_cost, tip_percent, tax_percent) {
// Write your code here
const tip = meal_cost/100*tip_percent
const tax = tax_percent/100*tip_percent
const total_cost = meal_cost + tip + tax
console.log(Math.round(total_cost)
)
}
function main() {
const meal_cost = parseFloat(readLine().trim());
const tip_percent = parseInt(readLine().trim(), 10);
const tax_percent = parseInt(readLine().trim(), 10);
solve(meal_cost, tip_percent, tax_percent);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment