Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function goldMine(input) {
- let locations = Number(input[0])
- for (let i = 1; i <= input.length; i++) {
- let avgExtraction = Number(input[i])
- i++
- let days = Number(input[i])
- i++
- let totalExtraction = 0;
- for (let j = i; j < i + days; j++) {
- let current = 0;
- current += Number(input[j])
- totalExtraction += current
- }
- totalExtraction /= days
- if (avgExtraction <= totalExtraction) {
- console.log(`Good job! Average gold per day: ${totalExtraction.toFixed(2)}.`)
- }
- if (avgExtraction > totalExtraction) {
- console.log(`You need ${(avgExtraction - totalExtraction).toFixed(2)} gold.`)
- }
- i = i + days - 1 // etozi kod mi dade 80to4ki
- }
- }
- goldMine([4,
- 10,
- 3,
- 10,
- 10,
- 11,
- 20,
- 2,
- 20,
- 10,
- "5",
- "3",
- "10",
- "1",
- "3",
- "5",
- "3",
- "10",
- "1",
- "3"
- ])
- goldMine(["1",
- "5",
- "3",
- "10",
- "1",
- "3"
- ])
- goldMine(["1",
- "5",
- "3",
- "10",
- "1",
- "3"
- ])
- function christmasGifts(input) {
- let adults = 0;
- let kids = 0;
- for (let i = 0; i < input.length; i++) {
- if (input[i] == 'Christmas') {
- break
- }
- if (Number(input[i] <= 16)) {
- kids++
- } else {
- adults++
- }
- }
- console.log(`Number of adults: ${adults}`)
- console.log(`Number of kids: ${kids}`)
- console.log(`Money for toys: ${kids*5}`)
- console.log(`Money for sweaters: ${adults*15}`)
- }
- christmasGifts([16,
- 20,
- 46,
- 12,
- 8,
- 20,
- 49,
- 'Christmas'
- ])
- christmasGifts([
- 16,
- 16,
- 16,
- 16,
- 16,
- 'Christmas'
- ])
- function catFood(input) {
- let cats = Number(input[0]);
- let smallCats = 0;
- let middleCats = 0;
- let bigCats = 0;
- let totalFood = 0;
- for (let i = 1; i <= cats; i++) {
- totalFood += Number(input[i])
- if (input[i] < 200) {
- smallCats++
- } else if (input[i] < 300) {
- middleCats++
- } else {
- bigCats++
- }
- }
- console.log(`Group 1: ${smallCats} cats.`)
- console.log(`Group 2: ${middleCats} cats.`)
- console.log(`Group 3: ${bigCats} cats.`)
- console.log(`Price for food per day: ${((totalFood/1000)*12.45).toFixed(2)} lv.`)
- }
- catFood(["7",
- "100",
- "200",
- "342",
- "300",
- "234",
- "123",
- "212"
- ])
- catFood(["10",
- "256",
- "348",
- "198",
- "322",
- "186",
- "294",
- "321",
- "100",
- "200",
- "300"
- ])
- function pastryShop(input) {
- let candy = input[0]
- let amount = Number(input[1])
- let day = Number(input[2])
- let price = 0;
- switch (candy) {
- case 'Cake':
- if (day <= 15) {
- price += 24
- price *= amount
- } else {
- price += 28.7
- price *= amount
- }
- break;
- case 'Souffle':
- if (day <= 15) {
- price += 6.66
- price *= amount
- } else {
- price += 9.8
- price *= amount
- }
- break;
- case 'Baklava':
- if (day <= 15) {
- price += 12.6
- price *= amount
- } else {
- price += 16.98
- price *= amount
- }
- break;
- }
- if (day <= 22) {
- if (price >= 100 && price <= 200) {
- price *= .85
- } else if (price > 200) {
- price *= .75
- }
- }
- if (day <= 15) {
- price *= .9
- }
- console.log(price.toFixed(2))
- }
- pastryShop(["Cake",
- "10",
- "15"
- ])
- pastryShop(["Souffle",
- "20",
- "24"
- ])
- pastryShop(["Baklava",
- "50",
- "1"
- ])
- pastryShop(["Cake",
- "5",
- "12"
- ])
- function aND(input) {
- let amount = Number(input[0]);
- let workers = Number(input[1]);
- let workingDays = Number(input[2]);
- let total = 8 * workers * workingDays;
- total = Math.floor(total / 3)
- if (amount > total) {
- console.log(`Losses: -> ${ ((amount-total) *110.1).toFixed(2)} BGN`)
- } else {
- console.log(`Profit: -> ${ ((total-amount) *110.1).toFixed(2)} BGN`)
- }
- }
- aND(["500",
- "8",
- "20"
- ])
- aND(["150",
- "7",
- "18"
- ])
- function proggramingBook(input) {
- let a = Number(input[0])
- let b = Number(input[1])
- let c = Number(input[2])
- let d = Number(input[3])
- let e = Number(input[4])
- let money = ((((a * 899 + b * 2) * ((100 - c) * 0.01))) + d) * ((100 - e) * 0.01)
- console.log(`Avtonom should pay ${money.toFixed(2)} BGN.`)
- }
- proggramingBook(["0.02",
- "0.50",
- "18",
- "21",
- "50"
- ])
- proggramingBook(["0.05",
- "1.20",
- "40",
- "19.99",
- "20"
- ])
- proggramingBook(["0.01",
- "1",
- "10",
- "20",
- "20"
- ])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement