Hotel Bill
A Hotel is offering discounts to its customers.
Given charge per day
dayCharge based on category and numbers of days customer stayed days as inputs, write a JS arrow function to return the total bill with the discount.
Quick Tip
Apply discounts on the following basis,
Sample Input 1
200
3
Sample Output 1
570
Sample Input 2
180
1
Sample Output 2
180
i want the code in between write code here
"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");
let inputString = "";
let currentLine = 0;
process.stdin.on("data", (inputStdin) => {
inputString += inputStdin;
});
process.stdin.on("end", (_) => {
inputString = inputString.trim().split("\n").map((str) => str.trim());
main();
});
function readLine() {
return inputString[currentLine++];
}
/* Please do not modify anything above this line */
function main() {
const dayCharge = JSON.parse(readLine());
const days = parseInt(readLine());
/* Write your code here */
}
'use strict';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', inputStdin => {
inputString += inputStdin;
});
process.stdin.on('end', _ => {
inputString = inputString.trim().split('\n').map(string => {
return string.trim();
});
main();
});
function readLine() {
return inputString[currentLine++];
}
/**** Ignore above this line. ****/
function main() {
const dayCharge = JSON.parse(readLine());
const days = parseInt(readLine());
let bill, discount;
bill = dayCharge * days;
if (days >= 2) {
discount = 5;
bill - (bill * discount) / 100;
}
if (days >= 5) {
discount = 15;
bill - (bill * discount) / 100;
}
console.log(`Total bill with the discont is ${bill}`);
}
Comments
Leave a comment