Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input) {
- let sum = 0;
- let sum2 = 0;
- let sum3 = 0;
- let input0 = Number(input[0]);
- let input1 = Number(input[1]);
- let input2 = Number(input[2]);
- let input3 = Number(input[3]);
- // Kilograms
- // sum is the price for a given kilograms
- if (input1 < 10) {
- sum = input0 * (20 / 100); // This is the price up to 10kg.
- } else if (10 < input1 && input1 <= 20) {
- sum = input0 * (50 / 100); // This is the price between 10 and 20kg.
- } else if (input1 > 20) { // This is the price for above 20kg.
- sum = input0;
- }
- // Days
- // sum2 is the price increase given the days
- if (input2 > 30 ) {
- sum2 = sum * (10 / 100); // The price beyond 30 days.
- } else if (7 <= input2 && input2 <= 30) {
- sum2 = sum * (15 / 100); // The price between 7 and 30 days.
- } else if (input2 < 7) {
- sum2 = sum * (40 / 100); // The price below 7 days.
- }
- // sum3 is the result of the price for given kilograms and the the additional price for the given days
- sum3 = Number(sum) + Number(sum2);
- // total is the multiplication of the total sum that has to be paid for one baggage and the baggages that are stored
- let total = sum3 * input3;
- console.log('The total price of bags is: ' + total.toFixed(2) + ' lv.')
- }
Advertisement
Add Comment
Please, Sign In to add comment