Advertisement
dilyana2001

Untitled

Jun 20th, 2021
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function goldMine(input) {
  2.     let locations = Number(input[0])
  3.     for (let i = 1; i <= input.length; i++) {
  4.         let avgExtraction = Number(input[i])
  5.         i++
  6.         let days = Number(input[i])
  7.         i++
  8.         let totalExtraction = 0;
  9.         for (let j = i; j < i + days; j++) {
  10.             let current = 0;
  11.             current += Number(input[j])
  12.             totalExtraction += current
  13.         }
  14.         totalExtraction /= days
  15.         if (avgExtraction <= totalExtraction) {
  16.             console.log(`Good job! Average gold per day: ${totalExtraction.toFixed(2)}.`)
  17.         }
  18.         if (avgExtraction > totalExtraction) {
  19.             console.log(`You need ${(avgExtraction - totalExtraction).toFixed(2)} gold.`)
  20.         }
  21.  
  22.         i = i + days - 1 // etozi kod mi dade 80to4ki
  23.  
  24.     }
  25. }
  26. goldMine([4,
  27.     10,
  28.     3,
  29.     10,
  30.     10,
  31.     11,
  32.     20,
  33.     2,
  34.     20,
  35.     10,
  36.     "5",
  37.     "3",
  38.     "10",
  39.     "1",
  40.     "3",
  41.     "5",
  42.     "3",
  43.     "10",
  44.     "1",
  45.     "3"
  46. ])
  47. goldMine(["1",
  48.     "5",
  49.     "3",
  50.     "10",
  51.     "1",
  52.     "3"
  53. ])
  54. goldMine(["1",
  55.     "5",
  56.     "3",
  57.     "10",
  58.     "1",
  59.     "3"
  60. ])
  61.  
  62.  
  63.  
  64. function christmasGifts(input) {
  65.     let adults = 0;
  66.     let kids = 0;
  67.  
  68.     for (let i = 0; i < input.length; i++) {
  69.         if (input[i] == 'Christmas') {
  70.             break
  71.         }
  72.         if (Number(input[i] <= 16)) {
  73.             kids++
  74.         } else {
  75.             adults++
  76.         }
  77.     }
  78.     console.log(`Number of adults: ${adults}`)
  79.     console.log(`Number of kids: ${kids}`)
  80.     console.log(`Money for toys: ${kids*5}`)
  81.     console.log(`Money for sweaters: ${adults*15}`)
  82. }
  83.  
  84. christmasGifts([16,
  85.     20,
  86.     46,
  87.     12,
  88.     8,
  89.     20,
  90.     49,
  91.     'Christmas'
  92. ])
  93. christmasGifts([
  94.     16,
  95.     16,
  96.     16,
  97.     16,
  98.     16,
  99.     'Christmas'
  100. ])
  101.  
  102.  
  103. function catFood(input) {
  104.     let cats = Number(input[0]);
  105.     let smallCats = 0;
  106.     let middleCats = 0;
  107.     let bigCats = 0;
  108.     let totalFood = 0;
  109.     for (let i = 1; i <= cats; i++) {
  110.         totalFood += Number(input[i])
  111.         if (input[i] < 200) {
  112.             smallCats++
  113.         } else if (input[i] < 300) {
  114.             middleCats++
  115.         } else {
  116.             bigCats++
  117.         }
  118.     }
  119.     console.log(`Group 1: ${smallCats} cats.`)
  120.     console.log(`Group 2: ${middleCats} cats.`)
  121.     console.log(`Group 3: ${bigCats} cats.`)
  122.     console.log(`Price for food per day: ${((totalFood/1000)*12.45).toFixed(2)} lv.`)
  123. }
  124. catFood(["7",
  125.     "100",
  126.     "200",
  127.     "342",
  128.     "300",
  129.     "234",
  130.     "123",
  131.     "212"
  132. ])
  133. catFood(["10",
  134.     "256",
  135.     "348",
  136.     "198",
  137.     "322",
  138.     "186",
  139.     "294",
  140.     "321",
  141.     "100",
  142.     "200",
  143.     "300"
  144. ])
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157. function pastryShop(input) {
  158.     let candy = input[0]
  159.     let amount = Number(input[1])
  160.     let day = Number(input[2])
  161.     let price = 0;
  162.     switch (candy) {
  163.         case 'Cake':
  164.             if (day <= 15) {
  165.                 price += 24
  166.                 price *= amount
  167.             } else {
  168.                 price += 28.7
  169.                 price *= amount
  170.             }
  171.             break;
  172.         case 'Souffle':
  173.             if (day <= 15) {
  174.                 price += 6.66
  175.                 price *= amount
  176.             } else {
  177.                 price += 9.8
  178.                 price *= amount
  179.             }
  180.             break;
  181.         case 'Baklava':
  182.             if (day <= 15) {
  183.                 price += 12.6
  184.                 price *= amount
  185.             } else {
  186.                 price += 16.98
  187.                 price *= amount
  188.             }
  189.             break;
  190.     }
  191.     if (day <= 22) {
  192.         if (price >= 100 && price <= 200) {
  193.             price *= .85
  194.         } else if (price > 200) {
  195.             price *= .75
  196.         }
  197.     }
  198.     if (day <= 15) {
  199.         price *= .9
  200.     }
  201.     console.log(price.toFixed(2))
  202. }
  203. pastryShop(["Cake",
  204.     "10",
  205.     "15"
  206. ])
  207.  
  208. pastryShop(["Souffle",
  209.     "20",
  210.     "24"
  211. ])
  212. pastryShop(["Baklava",
  213.     "50",
  214.     "1"
  215. ])
  216. pastryShop(["Cake",
  217.     "5",
  218.     "12"
  219. ])
  220.  
  221.  
  222.  
  223. function aND(input) {
  224.     let amount = Number(input[0]);
  225.     let workers = Number(input[1]);
  226.     let workingDays = Number(input[2]);
  227.  
  228.     let total = 8 * workers * workingDays;
  229.     total = Math.floor(total / 3)
  230.  
  231.     if (amount > total) {
  232.         console.log(`Losses: -> ${ ((amount-total) *110.1).toFixed(2)} BGN`)
  233.     } else {
  234.         console.log(`Profit: -> ${ ((total-amount) *110.1).toFixed(2)} BGN`)
  235.     }
  236. }
  237.  
  238. aND(["500",
  239.     "8",
  240.     "20"
  241. ])
  242. aND(["150",
  243.     "7",
  244.     "18"
  245. ])
  246.  
  247.  
  248.  
  249. function proggramingBook(input) {
  250.     let a = Number(input[0])
  251.     let b = Number(input[1])
  252.     let c = Number(input[2])
  253.     let d = Number(input[3])
  254.     let e = Number(input[4])
  255.     let money = ((((a * 899 + b * 2) * ((100 - c) * 0.01))) + d) * ((100 - e) * 0.01)
  256.  
  257.     console.log(`Avtonom should pay ${money.toFixed(2)} BGN.`)
  258. }
  259. proggramingBook(["0.02",
  260.     "0.50",
  261.     "18",
  262.     "21",
  263.     "50"
  264. ])
  265. proggramingBook(["0.05",
  266.     "1.20",
  267.     "40",
  268.     "19.99",
  269.     "20"
  270. ])
  271.  
  272. proggramingBook(["0.01",
  273.     "1",
  274.     "10",
  275.     "20",
  276.     "20"
  277. ])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement