• + 2 comments

    Hi,

    I'm using JavaScript and knows how to solve this problem, but I'm not familiar with these i/o methods that's being used. Can someone here guide me on the problem with my code? I'm still trying to get used to how this site works.

    function processData(input, tips, taxes) {
    //Enter your code here
    var mealCost = input,
        tipPercent = tips,
        taxPercent = taxes,
        tip = mealCost * (tipPercent / 100),
        tax = mealCost * (taxPercent / 100),
        totalCost = Math.round(mealCost + tip + tax);
    
        return totalCost;
    } 
    
    process.stdout.write('The total meal cost is ' + processData(12, 20, 8) + ' dollars.');
    process.stdout.write('The total meal cost is ' + processData(15.50, 15, 10) + ' dollars.');
    
    process.stdin.resume();
    process.stdin.setEncoding("ascii");
    _input = "";
    process.stdin.on("data", function (input) {
    _input += input;
    });
    
    process.stdin.on("end", function () {
        processData(_input);
    });