Skip to content

Solution/m1 008 #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
d84e338
Solution M1-001
saratemwhy Sep 7, 2023
6081ddd
Solution m1-002
saratemwhy Sep 16, 2023
07cdb39
solution m1-003
saratemwhy Sep 26, 2023
cd06420
solution m1-003
saratemwhy Sep 26, 2023
4c3014a
Merge branch 'solution/m1-003' of github.com:saratemwhy/programming-b…
saratemwhy Sep 26, 2023
4bc6208
solution m1-003
saratemwhy Sep 26, 2023
d732df9
solution/m1-003
saratemwhy Sep 26, 2023
0d83970
Merge branch 'solution/m1-003' of github.com:saratemwhy/programming-b…
saratemwhy Sep 26, 2023
2c3574c
solution/m1-003
saratemwhy Sep 26, 2023
69d8f0b
Solution/m1-003
saratemwhy Sep 27, 2023
b06bfb0
Merge branch 'solution/m1-003' of github.com:saratemwhy/programming-b…
saratemwhy Sep 27, 2023
f044437
console log
saratemwhy Sep 27, 2023
f081d5d
Merge pull request #1 from saratemwhy/solution/m1-001
saratemwhy Sep 27, 2023
78abb39
Merge branch 'main' into main
saratemwhy Sep 27, 2023
b70d4b3
Merge pull request #2 from saratemwhy/solution/m1-002
saratemwhy Sep 27, 2023
1b7d801
Merge pull request #3 from saratemwhy/solution/m1-003
saratemwhy Sep 27, 2023
008b2ef
solution m1-004
saratemwhy Sep 30, 2023
2fc5759
Merge pull request #4 from saratemwhy/solution/m1-004
saratemwhy Sep 30, 2023
c17eded
solution m1-005
saratemwhy Oct 3, 2023
054c8a3
Merge pull request #5 from saratemwhy/solution/m1-005
saratemwhy Oct 3, 2023
89e98cb
solution m1-007
saratemwhy Oct 9, 2023
dc5512e
Merge pull request #6 from saratemwhy/solution/m1-007
saratemwhy Oct 9, 2023
7064f0f
solution m1-008
saratemwhy Oct 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions projects/001-area-of-a-room/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,18 @@ For this project solution you may use:
- Strings

# Test
Execute the test to validate your solution.

**VSCODE**
To run the test command from the README.md install the extension **runme**.
Press Ctrl+Shift+x search and install the **runme** extension.
Execute the test to validate your solution.

**VSCODE**
To run the test command from the README.md install the extension **runme**.
Press Ctrl+Shift+x search and install the **runme** extension.

**Python**

```sh
python -m unittest python/test_area_of_a_room.py
python -m unittest python\test_area_of_a_room.py

```

or run the command from the terminal
Expand Down
6 changes: 6 additions & 0 deletions projects/001-area-of-a-room/js/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
let lengthRoom = prompt("Inserisci la lunghezza della tua stanza in metri: ");
let widthRoom = prompt("Inserisci la larghezza della tua stanza in metri: ");

let areaRoom = +(lengthRoom * widthRoom).toFixed(8);

console.log("L'area della tua stanza è di" + " " + areaRoom);
Binary file not shown.
Binary file not shown.
6 changes: 6 additions & 0 deletions projects/001-area-of-a-room/python/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
length_room = float(input("Inserisci la lunghezza della stanza in metri: "))
width_room = float(input("Inserisci larghezza della stanza in metri: "))

area_room = round(length_room * width_room, 2)

print("L'area della tua stanza è di ", str(area_room), " mq")
21 changes: 21 additions & 0 deletions projects/002-bottle-deposits/js/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@


let little_bottle = prompt ("Quante bottiglie da un litro o meno hai?");

let big_bottle = prompt ("Quante bottiglie da più di un litro hai?");

let deposit_litttleBottle = little_bottle * 0.10;

console.log("Il tuo resto è di " + deposit_litttleBottle.toFixed(2) + "$");

let deposit_bigBottle = big_bottle * 0.25;

console.log("Il tuo resto è di " + deposit_bigBottle.toFixed(2) + "$");








34 changes: 34 additions & 0 deletions projects/003-making-change/js/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
let coins = [200, 100, 25, 10, 5, 1];

let cash = 742;

let coinsValue = [];

let coinsName = ['toonie,', 'loonie,', 'quarter,', 'dime,', 'nickel,', 'penny.'];

function checkout (cash, coins) {

for ( let i=0; i<coins.length; i++) {
if (coins[i] < cash) {
let division = Math.trunc(cash/coins[i]);
coinsValue.push(division);
cash=cash%coins[i];
} else {
coinsValue.push(0);
}
}
}

checkout(cash, coins);


function message (){
let output = cash + 'cents = ';
for (let n=0; n<coinsValue.length; n++) {
output += coinsValue[n] + ' ' + coinsName[n];
}

console.log(output)
}

message();
15 changes: 15 additions & 0 deletions projects/004-units-of-time/js/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
let ask_days = prompt("Inserisci i giorni: ");
let ask_hours = prompt("Inserisci le ore: ");
let ask_minutes = prompt("Inserisci i minuti: ");
let ask_seconds = prompt("Inserisci i secondi: ");


function resultSeconds (ask_days, ask_hours, ask_minutes, ask_seconds) {
return((ask_days*86400)+(ask_hours*3600)+(ask_minutes*60)+(ask_seconds*1));
}



console.log(resultSeconds(ask_days, ask_hours, ask_minutes, ask_seconds));


16 changes: 16 additions & 0 deletions projects/005-units-of-time-again/js/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
let inputSec = prompt("Inserisci i secondi: ");

function convertSec (inputSec) {
const secToDays = parseInt (inputSec/(24*3600));
inputSec = inputSec % (24*3600);
const secToHour = parseInt (inputSec/3600);
inputSec %= 3600;
const secToMinutes = parseInt (inputSec/60);
inputSec %= 60;
const secToSec = inputSec;

console.log(secToDays + ":" + secToHour + ":" + secToMinutes + ":" + secToSec);
}

convertSec(inputSec);

13 changes: 13 additions & 0 deletions projects/007-day-old-bread/js/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
let oldBread = 15;

let breadPrice = 3.49;

let regularPrice = oldBread * breadPrice;

let discountPrice = (regularPrice * 60)/100;

let totalPrice = regularPrice - discountPrice;

console.log (' Input = ' + oldBread + "\n", 'Regular price = ' + regularPrice.toFixed(2) + '€' + "\n", 'Discount =' + discountPrice.toFixed(2) + '€' + "\n", 'Total price =' + totalPrice.toFixed(2) + '€');


14 changes: 14 additions & 0 deletions projects/008-dog-years/js/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
let humanyears = prompt ('Quanti anni ha il tuo cane?');

let dogyears = 0;

if (humanyears <= 0) {
alert ('Inserisci un numero positivo!');
} else if (humanyears <= 2) {
dogyears = 10,5 * dogyears;
} else {
dogyears = (10.5*2) + ((humanyears-2)*4);
}

console.log(dogyears.toFixed(1));