Skip to content

Solution/m1 006 #36

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 21 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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);

15 changes: 15 additions & 0 deletions projects/006-sum-of-digits-in-a-integer/js/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
let inputNumber = prompt ("Inserisci un numero di quattro cifre: ");


if (inputNumber.length !== 4){
console.log ("Non hai inserito 4 cifre!");
} else {
const separateNumber = Array.from(String(inputNumber), Number);
let sumNumber = 0;

for (let i = 0; i < separateNumber.length; i++) {
sumNumber += separateNumber[i];
}

console.log(separateNumber[0] + '+' + separateNumber[1] + '+' + separateNumber[2] + '+' + separateNumber[3] + '=' + sumNumber);
}