Skip to content

Commit fc1ba80

Browse files
committed
[NEW] Exercice 19
1 parent 653d55e commit fc1ba80

File tree

2 files changed

+97
-0
lines changed

2 files changed

+97
-0
lines changed

Exercice_19/exercice19.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/****************************************** EXERCICE 19 *******************************************/
2+
3+
var readline = require("readline-sync");
4+
5+
const DOLLAR = 1.22;
6+
const ROUBLE = 91.14;
7+
const YUAN = 7.89;
8+
const LIVRE = 0.89;
9+
10+
var montant = readline.questionFloat("Saisir la somme en euro à convertir : ");
11+
afficherMenuDevise();
12+
13+
var montantConverti = 0;
14+
var devise;
15+
16+
do {
17+
devise = readline.question("Saisir la devise souhaitée : ");
18+
switch (devise) {
19+
case "$":
20+
montantConverti = DOLLAR * montant;
21+
break;
22+
case "Dollars":
23+
montantConverti = DOLLAR * montant;
24+
break;
25+
case "Roubles":
26+
montantConverti = ROUBLE * montant;
27+
break;
28+
case "Yuans":
29+
montantConverti = YUAN * montant;
30+
break;
31+
case "£":
32+
montantConverti = LIVRE * montant;
33+
break;
34+
case "Libres":
35+
montantConverti = LIVRE * montant;
36+
break;
37+
default:
38+
console.log("La devise choisie n'est pas prise en compte");
39+
break;
40+
}
41+
} while (montantConverti === 0);
42+
43+
console.log(montant + "€ = " + montantConverti + " " + devise);
44+
45+
function afficherMenuDevise() {
46+
var msg = "****************************************\n";
47+
msg += "$ ou Dollars (US)\n";
48+
msg += "Roubles (Russie)\n";
49+
msg += "Yuans (Chine)\n";
50+
msg += "£ ou Livres (Royaume-Uni)\n";
51+
console.log(msg);
52+
}

Exercice_19/exercice19.pseudoc

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/****************************************** EXERCICE 19 *******************************************/
2+
3+
FONCTION afficherMenuDevise
4+
VARIABLES
5+
msg : CHAINE DE CARACTERE
6+
DÉBUT
7+
msg → "****************************************\n"
8+
msg → msg + "$ ou Dollars (US)\n"
9+
msg → msg + "Roubles (Russie)\n"
10+
msg → msg + "Yuans (Chine)\n"
11+
msg → msg + "£ ou Livres (Royaume-Uni)\n"
12+
AFFICHER msg
13+
FIN
14+
15+
ALGORITHME main
16+
VARIABLES
17+
CONSTANTE DECIMAL DOLLAR → 1,22
18+
CONSTANTE DECIMAL ROUBLE → 91,14
19+
CONSTANTE DECIMAL YUAN → 7,89
20+
CONSTANTE DECIMAL LIVRE → 0,89
21+
montant,montantConverti : DECIMAL
22+
devise : CHAINE DE CARACTERE
23+
DÉBUT
24+
AFFICHER "Saisir la somme en euro à convertir : "
25+
SAISIR somme
26+
27+
afficherMenuDevise()
28+
montantConverti → 0
29+
30+
FAIRE
31+
AFFICHER "Saisir la devise souhaitée : "
32+
SAISIR devise
33+
SELON devise
34+
CAS "$" : montantConverti → DOLLAR * montant
35+
CAS "Dollars" : montantConverti → DOLLAR * montant
36+
CAS "Roubles" : montantConverti → ROUBLE * montant
37+
CAS "Yuans" : montantConverti → YUAN * montant
38+
CAS "£" : montantConverti → LIVRE * montant
39+
CAS "Libres" : montantConverti → LIVRE * montant
40+
AUTREMENT : AFFICHER "La devise choisie n'est pas prise en compte"
41+
FINSELON
42+
TANT QUE (montantConverti = 0)
43+
44+
AFFICHER montant, "€ = ", montantConverti, " ", devise
45+
FIN

0 commit comments

Comments
 (0)