Advertisement
Guest User

Untitled

a guest
May 23rd, 2020
479
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(city, salary) {
  2.     city = String(city);
  3.     salary = Number(salary);
  4.     let bonus = 0;
  5.  
  6.     if (city === "Sofia") {
  7.         if (salary >= 0 && salary <= 500) {
  8.             bonus = salary * 0.05;
  9.             console.log(bonus.toFixed(2));
  10.         } else if (salary > 500 && salary <= 1000) {
  11.             bonus = salary * 0.07;
  12.             console.log(bonus.toFixed(2));
  13.         } else if (salary > 1000 && salary <= 10000) {
  14.             bonus = salary * 0.08;
  15.             console.log(bonus.toFixed(2));
  16.         } else if (salary > 10000) {
  17.             bonus = salary * 0.12;
  18.             console.log(bonus.toFixed(2));
  19.         } else if (salary < 0) {
  20.             console.log("error")
  21.         }
  22.     } if (city === "Varna") {
  23.         if (salary >= 0 && salary <= 500) {
  24.             bonus = salary * 0.045;
  25.             console.log(bonus.toFixed(2));
  26.         } else if (salary > 500 && salary <= 1000) {
  27.             bonus = salary * 0.075;
  28.             console.log(bonus.toFixed(2));
  29.         } else if (salary > 1000 && salary <= 10000) {
  30.             bonus = salary * 0.10;
  31.             console.log(bonus.toFixed(2));
  32.         } else if (salary > 10000) {
  33.             bonus = salary * 0.13;
  34.             console.log(bonus.toFixed(2));
  35.         } else if (salary < 0){
  36.             console.log("error")
  37.         }
  38.     } if (city === "Plovdiv") {
  39.         if (salary >= 0 && salary <= 500) {
  40.             bonus = salary * 0.055;
  41.             console.log(bonus.toFixed(2));
  42.         } else if (salary > 500 && salary <= 1000) {
  43.             bonus = salary * 0.08;
  44.             console.log(bonus.toFixed(2));
  45.         } else if (salary > 1000 && salary <= 10000) {
  46.             bonus = salary * 0.12;
  47.             console.log(bonus.toFixed(2));
  48.         } else if (salary > 10000) {
  49.             bonus = salary * 0.145;
  50.             console.log(bonus.toFixed(2));
  51.         } else if (salary < 0) {
  52.             console.log("error")
  53.         }
  54.     } else {
  55.         console.log("error")
  56.     }
  57.    
  58.  
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement