Skip to content

Commit be6f128

Browse files
adding more exercises
first steps in coding
1 parent d485425 commit be6f128

10 files changed

+119
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
function calculateTrapezoidArea(input) {
2+
let b1 = parseFloat(input[0]);
3+
let b2 = parseFloat(input[1]);
4+
let height = parseFloat(input[2]);
5+
let area = (b1 + b2) * height / 2;
6+
console.log(area.toFixed(2));
7+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
function calculateTriangleArea(input) {
2+
let a = parseFloat(input[0]);
3+
let h = parseFloat(input[1]);
4+
let area = a * h / 2;
5+
console.log(area.toFixed(2));
6+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
function celsiusToFahrenheit(input) {
2+
let degreesCelsius = parseFloat(input[0]);
3+
let degreesFahrenheit = degreesCelsius * 1.8 + 32;
4+
console.log(degreesFahrenheit.toFixed(2));
5+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
function vegetableMarket(input) {
2+
let priceKiloVegetables = parseFloat(input[0]);
3+
let priceKiloFruits = parseFloat(input[1]);
4+
let totalKilosVegetables = parseInt(input[2]);
5+
let totalKilosFruits = parseInt(input[3]);
6+
7+
let totalVegetables = priceKiloVegetables * totalKilosVegetables;
8+
let totalFruits = priceKiloFruits * totalKilosFruits;
9+
let total = totalVegetables + totalFruits;
10+
let totalEuro = total / 1.94;
11+
12+
console.log(totalEuro.toFixed(2));
13+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
function calculateDesks(input) {
2+
let length = parseFloat(input[0]);
3+
let width = parseFloat(input[1]) - 1;
4+
5+
let widthDesks = Math.floor(width / 0.7);
6+
let lengthDesks = Math.floor(length / 1.2);
7+
8+
let freeSpace = widthDesks * lengthDesks - 3;
9+
10+
console.log(freeSpace.toFixed(0));
11+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
function fishMarket(input) {
2+
let mackerelPrice = parseFloat(input[0]);
3+
let spratPrice = parseFloat(input[1]);
4+
let bonitoKilos = parseFloat(input[2]);
5+
let scadKilos = parseFloat(input[3]);
6+
let clamsKilos = parseInt(input[4]);
7+
8+
let bonitoPrice = mackerelPrice + mackerelPrice * 0.60;
9+
let scadPrice = spratPrice + spratPrice * 0.80;
10+
let clamsPrice = clamsKilos * 7.50;
11+
12+
let bonito = bonitoKilos * bonitoPrice;
13+
let scad = scadKilos * scadPrice;
14+
15+
let total = clamsPrice + bonito + scad;
16+
17+
console.log(total.toFixed(2));
18+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
function housePainting(input) {
2+
let x = parseFloat(input[0]);
3+
let y = parseFloat(input[1]);
4+
let h = parseFloat(input[2]);
5+
6+
let sideWall = x * y;
7+
let window = 1.5 * 1.5;
8+
let sides = 2 * sideWall - 2 * window;
9+
let backWall = x * x;
10+
let entrance = 1.2 * 2;
11+
let frontAndBack = 2 * backWall - entrance;
12+
13+
let totalAreaWalls = sides + frontAndBack;
14+
let greenPaint = totalAreaWalls / 3.4;
15+
16+
let roof = 2 * (x * y);
17+
let triangle = 2 * (x * h / 2);
18+
19+
let totalAreaRoof = roof + triangle;
20+
let redPaint = totalAreaRoof / 4.3;
21+
22+
console.log(greenPaint.toFixed(2));
23+
console.log(redPaint.toFixed(2));
24+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
function circleAreaAndPerimeter(input) {
2+
let radians = parseFloat(input[0]);
3+
4+
let perimeter = 2 * Math.PI * radians;
5+
let area = Math.PI * radians * radians;
6+
7+
console.log(area.toFixed(2));
8+
console.log(perimeter.toFixed(2));
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
function weatherForecast(input) {
2+
let text = input[0];
3+
4+
if(text === "sunny") {
5+
console.log("It's warm outside!");
6+
} else {
7+
console.log("It's cold outside!");
8+
}
9+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
function weatherForecastPart2(input) {
2+
let degrees = parseFloat(input[0]);
3+
4+
if(degrees >= 26.00 && degrees <= 35.00) {
5+
console.log("Hot");
6+
} else if(degrees >= 20.1 && degrees <= 25.9) {
7+
console.log("Warm");
8+
} else if(degrees >= 15.00 && degrees <= 20.00) {
9+
console.log("Mild");
10+
} else if(degrees >= 12.00 && degrees <= 14.9) {
11+
console.log("Cool");
12+
} else if(degrees >= 5.00 && degrees <= 11.9) {
13+
console.log("Cold");
14+
} else {
15+
console.log("unknown");
16+
}
17+
}

0 commit comments

Comments
 (0)