Skip to content

Commit 7318738

Browse files
Add files via upload
1 parent cb33b8e commit 7318738

31 files changed

+1072
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
function cinema(input) {
2+
const projectionType = input[0];
3+
const rows = Number(input[1]);
4+
const columns = Number(input[2]);
5+
let sum = 0;
6+
7+
if (projectionType === "Premiere") {
8+
sum = rows * columns * 12.00;
9+
} else if (projectionType === "Normal") {
10+
sum = rows * columns * 7.50;
11+
} else if (projectionType === "Discount") {
12+
sum = rows * columns * 5.00;
13+
}
14+
console.log(`${sum.toFixed(2)} leva`);
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
function summerOutfit(input) {
2+
const degrees = Number(input[0]);
3+
const time = input[1];
4+
let outfit = "";
5+
let shoes = "";
6+
7+
if (time === "Morning") {
8+
if (degrees >= 10 && degrees <= 18) {
9+
outfit = "Sweatshirt";
10+
shoes = "Sneakers";
11+
} else if (degrees > 18 && degrees <= 24) {
12+
outfit = "Shirt";
13+
shoes = "Moccasins";
14+
} else if (degrees >= 25) {
15+
outfit = "T-Shirt";
16+
shoes = "Sandals";
17+
}
18+
} else if (time === "Afternoon") {
19+
if (degrees >= 10 && degrees <= 18) {
20+
outfit = "Shirt";
21+
shoes = "Moccasins";
22+
} else if (degrees > 18 && degrees <= 24) {
23+
outfit = "T-Shirt";
24+
shoes = "Sandals";
25+
} else if (degrees >= 25) {
26+
outfit = "Swim Suit";
27+
shoes = "Barefoot";
28+
}
29+
} else if (time === "Evening") {
30+
if (degrees >= 10 && degrees <= 18) {
31+
outfit = "Shirt";
32+
shoes = "Moccasins";
33+
} else if (degrees > 18 && degrees <= 24) {
34+
outfit = "Shirt";
35+
shoes = "Moccasins";
36+
} else if (degrees >= 25) {
37+
outfit = "Shirt";
38+
shoes = "Moccasins";
39+
}
40+
}
41+
console.log(`It's ${degrees} degrees, get your ${outfit} and ${shoes}.`);
42+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
function newHouse(input) {
2+
const flowerType = input[0];
3+
const numberOfFlowers = Number(input[1]);
4+
const budget = Number(input[2]);
5+
6+
let price = 0;
7+
8+
if (flowerType === "Roses") {
9+
price = numberOfFlowers * 5;
10+
if (numberOfFlowers > 80) {
11+
price = price - price * 0.10;
12+
}
13+
} else if (flowerType === "Dahlias") {
14+
price = numberOfFlowers * 3.80;
15+
if (numberOfFlowers > 90) {
16+
price = price - price * 0.15;
17+
}
18+
} else if (flowerType === "Tulips") {
19+
price = numberOfFlowers * 2.80;
20+
if (numberOfFlowers > 80) {
21+
price = price - price * 0.15;
22+
}
23+
} else if (flowerType === "Narcissus") {
24+
price = numberOfFlowers * 3;
25+
if (numberOfFlowers < 120) {
26+
price = price + price * 0.15;
27+
}
28+
} else if (flowerType === "Gladiolus") {
29+
price = numberOfFlowers * 2.50;
30+
if (numberOfFlowers < 80) {
31+
price = price + price * 0.20;
32+
}
33+
}
34+
const diff = Math.abs(budget - price);
35+
36+
if (budget >= price) {
37+
console.log(`Hey, you have a great garden with ${numberOfFlowers} ${flowerType} and ${diff.toFixed(2)} leva left.`);
38+
} else {
39+
console.log(`Not enough money, you need ${diff.toFixed(2)} leva more.`);
40+
}
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
function goFishing(input) {
2+
const budget = Number(input[0]);
3+
const season = input[1];
4+
const numberOfFishermen = Number(input[2]);
5+
6+
let price = 0;
7+
8+
if (season === "Spring") {
9+
price = 3000;
10+
if (numberOfFishermen <= 6) {
11+
price = price - price * 0.10;
12+
}
13+
if (numberOfFishermen >= 7 && numberOfFishermen <= 11) {
14+
price = price - price * 0.15;
15+
}
16+
if (numberOfFishermen >= 12) {
17+
price = price - price * 0.25;
18+
}
19+
20+
} else if (season === "Summer") {
21+
price = 4200;
22+
if (numberOfFishermen <= 6) {
23+
price = price - price * 0.10;
24+
}
25+
if (numberOfFishermen >= 7 && numberOfFishermen <= 11) {
26+
price = price - price * 0.15;
27+
}
28+
if (numberOfFishermen >= 12) {
29+
price = price - price * 0.25;
30+
}
31+
32+
} else if (season === "Autumn") {
33+
price = 4200;
34+
if (numberOfFishermen <= 6) {
35+
price = price - price * 0.10;
36+
}
37+
if (numberOfFishermen >= 7 && numberOfFishermen <= 11) {
38+
price = price - price * 0.15;
39+
}
40+
if (numberOfFishermen >= 12) {
41+
price = price - price * 0.25;
42+
}
43+
44+
} else if (season === "Winter") {
45+
price = 2600;
46+
if (numberOfFishermen <= 6) {
47+
price = price - price * 0.10;
48+
}
49+
if (numberOfFishermen >= 7 && numberOfFishermen <= 11) {
50+
price = price - price * 0.15;
51+
}
52+
if (numberOfFishermen >= 12) {
53+
price = price - price * 0.25;
54+
}
55+
}
56+
57+
if (season !== "Autumn") {
58+
if (numberOfFishermen % 2 == 0) {
59+
price = price - price * 0.05;
60+
}
61+
}
62+
63+
const diff = Math.abs(budget - price);
64+
65+
if (budget >= price) {
66+
console.log(`Yes! You have ${diff.toFixed(2)} leva left.`);
67+
} else {
68+
console.log(`Not enough money! You need ${diff.toFixed(2)} leva.`);
69+
}
70+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
function journey(input) {
2+
const budget = Number(input[0]);
3+
const season = input[1];
4+
let place = "";
5+
let price = 0;
6+
7+
if (budget <= 100) {
8+
console.log(`Somewhere in Bulgaria`);
9+
10+
if (season === "summer") {
11+
price = budget * 0.30;
12+
place = "Camp";
13+
} else if (season === "winter") {
14+
price = budget * 0.70;
15+
place = "Hotel";
16+
}
17+
18+
} else if (budget <= 1000) {
19+
console.log(`Somewhere in Balkans`);
20+
21+
if (season === "summer") {
22+
price = budget * 0.40;
23+
place = "Camp";
24+
} else if (season === "winter") {
25+
price = budget * 0.80;
26+
place = "Hotel";
27+
}
28+
29+
} else if (budget > 1000) {
30+
console.log(`Somewhere in Europe`);
31+
32+
price = budget * 0.90;
33+
place = "Hotel";
34+
}
35+
36+
console.log(`${place} - ${price.toFixed(2)}`);
37+
38+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
function operationBetweenNumbers(input) {
2+
const n1 = Number(input[0]);
3+
const n2 = Number(input[1]);
4+
const operator = input[2];
5+
6+
let calculation = 0;
7+
8+
if (operator === "+") {
9+
calculation = n1 + n2;
10+
if (calculation % 2 == 0) {
11+
console.log(`${n1} + ${n2} = ${calculation} - even`);
12+
13+
} else {
14+
console.log(`${n1} + ${n2} = ${calculation} - odd`);
15+
}
16+
17+
} else if (operator === "-") {
18+
calculation = n1 - n2;
19+
if (calculation % 2 == 0) {
20+
console.log(`${n1} - ${n2} = ${calculation} - even`);
21+
22+
} else {
23+
console.log(`${n1} - ${n2} = ${calculation} - odd`);
24+
}
25+
26+
} else if (operator === "*") {
27+
calculation = n1 * n2;
28+
if (calculation % 2 == 0) {
29+
console.log(`${n1} * ${n2} = ${calculation} - even`);
30+
31+
} else {
32+
console.log(`${n1} * ${n2} = ${calculation} - odd`);
33+
}
34+
35+
} else if (operator === "/") {
36+
if (n2 == 0) {
37+
console.log(`Cannot divide ${n1} by zero`);
38+
} else {
39+
const calculated = 1.0 * n1 / n2;
40+
console.log(`${n1} / ${n2} = ${calculated.toFixed(2)}`);
41+
42+
}
43+
44+
} else if (operator === "%") {
45+
if (n2 == 0) {
46+
console.log(`Cannot divide ${n1} by zero`);
47+
} else {
48+
calculation = n1 % n2;
49+
console.log(`${n1} % ${n2} = ${calculation}`);
50+
51+
}
52+
}
53+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
function hotelRoom(input) {
2+
const season = input[0];
3+
const nights = Number(input[1]);
4+
let priceApartment = 0;
5+
let priceStudio = 0;
6+
7+
if ((season === "May") || (season === "October")) {
8+
priceStudio = 50;
9+
priceApartment = 65;
10+
11+
if (nights > 7 && nights <= 14) {
12+
priceStudio = priceStudio - priceStudio * 0.05;
13+
14+
} else if (nights > 14) {
15+
priceStudio = priceStudio - priceStudio * 0.30;
16+
priceApartment = priceApartment - priceApartment * 0.10;
17+
}
18+
19+
priceStudio = nights * priceStudio;
20+
priceApartment = nights * priceApartment;
21+
22+
} else if ((season === "June") || (season === "September")) {
23+
priceStudio = 75.20;
24+
priceApartment = 68.70;
25+
26+
if (nights > 14) {
27+
priceStudio = priceStudio - priceStudio * 0.20;
28+
priceApartment = priceApartment - priceApartment * 0.10;
29+
}
30+
31+
priceStudio = nights * priceStudio;
32+
priceApartment = nights * priceApartment;
33+
34+
} else if ((season === "July") || (season === "August")) {
35+
priceStudio = 76;
36+
priceApartment = 77;
37+
38+
if (nights > 14) {
39+
priceApartment = priceApartment - priceApartment * 0.10;
40+
}
41+
42+
priceStudio = nights * priceStudio;
43+
priceApartment = nights * priceApartment;
44+
}
45+
46+
console.log(`Apartment: ${priceApartment.toFixed(2)} lv.`);
47+
console.log(`Studio: ${priceStudio.toFixed(2)} lv.`);
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
function onTime(input) {
2+
let examHour = Number(input[0]);
3+
let examMinute = Number(input[1]);
4+
let arriveHour = Number(input[2]);
5+
let arriveMinute = Number(input[3]);
6+
7+
let examTotalMinutes = examHour * 60 + examMinute;
8+
let arriveTotalMinutes = arriveHour * 60 + arriveMinute;
9+
10+
if (arriveTotalMinutes > examTotalMinutes) {
11+
console.log("Late");
12+
}
13+
else if (examTotalMinutes - arriveTotalMinutes <= 30) {
14+
console.log("On time");
15+
}
16+
else {
17+
console.log("Early");
18+
}
19+
20+
let result = Math.abs(examTotalMinutes - arriveTotalMinutes);
21+
if (examTotalMinutes - arriveTotalMinutes > 0) {
22+
if (result < 60) {
23+
console.log(`${result} minutes before the start`);
24+
} else {
25+
if (result % 60 < 10) {
26+
console.log(`${parseInt(result / 60)}:0${result % 60} hours before the start`);
27+
} else {
28+
console.log(`${parseInt(result / 60)}:${result % 60} hours before the start`);
29+
}
30+
}
31+
}
32+
else if (arriveTotalMinutes - examTotalMinutes > 0) {
33+
if (result < 60) {
34+
console.log(`${result} minutes after the start`);
35+
} else {
36+
if (result % 60 < 10) {
37+
console.log(`${parseInt(result / 60)}:0${result % 60} hours after the start`);
38+
} else {
39+
console.log(`${parseInt(result / 60)}:${result % 60} hours after the start`);
40+
}
41+
}
42+
}
43+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
function skiTrip(input) {
2+
const days = Number(input[0]);
3+
const roomType = input[1];
4+
const experience = input[2];
5+
6+
let nights = days - 1;
7+
let price = 0;
8+
9+
if (roomType === "room for one person") {
10+
price = 18 * nights;
11+
} else if (roomType === "apartment" && days < 10) {
12+
price = 25 * nights * 0.7;
13+
} else if (roomType === "apartment" && days >= 10 && days <= 15) {
14+
price = 25 * nights * 0.65;
15+
} else if (roomType === "apartment" && days > 15) {
16+
price = 25 * nights * 0.5;
17+
} else if (roomType === "president apartment" && days < 10) {
18+
price = 35 * nights * 0.9;
19+
} else if (roomType === "president apartment" && days >= 10 && days <= 15) {
20+
price = 35 * nights * 0.85;
21+
} else if (roomType === "president apartment" && days > 15) {
22+
price = 35 * nights * 0.8;
23+
}
24+
25+
if (experience === "positive") {
26+
price += 0.25 * price;
27+
} else if (experience === "negative") {
28+
price -= 0.1 * price;
29+
}
30+
31+
console.log(price.toFixed(2));
32+
}

0 commit comments

Comments
 (0)