Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function courierExpress(input) {
- let weight = parseFloat(input[0]);
- let typeCourier = input[1];
- let distance = parseInt(input[2]);
- let allPrice = 0.0;
- if (typeCourier === "standard") {
- if (weight < 1) {
- allPrice = distance * 0.03;
- } else if (weight >= 1 && weight <= 10) {
- allPrice = distance * 0.05;
- } else if (weight >= 11 && weight <= 40) {
- allPrice = distance * 0.10;
- } else if (weight >= 41 && weight <= 90) {
- allPrice = distance * 0.15;
- } else if (weight >= 91 && weight <= 150) {
- allPrice = distance * 0.20;
- }
- } else if (typeCourier === "express") {
- if (weight < 1) {
- allPrice = distance * 0.03 + 0.03 * 0.8 * weight * distance;
- } else if (weight >= 1 && weight <= 10) {
- allPrice = distance * 0.05 + 0.05 * 0.4 * weight * distance;
- } else if (weight >= 11 && weight <= 40) {
- allPrice = distance * 0.10 + 0.10 * 0.05 * weight * distance;
- } else if (weight >= 41 && weight <= 90) {
- allPrice = distance * 0.15 + 0.15 * 0.02 * weight * distance;
- } else if (weight >= 91 && weight <= 150) {
- allPrice = distance * 0.20 + 0.20 * 0.01 * weight * distance;
- }
- }
- const output = `The delivery of your shipment with weight of ${weight.toFixed(
- 3
- )} kg. would cost ${allPrice.toFixed(2)} lv.`;
- console.log(output);
- }
- courierExpress(["87", "express","130"]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement