Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Algorithmie
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mathias.catala
Algorithmie
Commits
aeec1ef4
Commit
aeec1ef4
authored
1 year ago
by
mathias.catala
Browse files
Options
Downloads
Patches
Plain Diff
"adding bancomat"
parent
bac6e98b
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
bancomat.scala
+114
-127
114 additions, 127 deletions
bancomat.scala
with
114 additions
and
127 deletions
bancomat.scala
+
114
−
127
View file @
aeec1ef4
import
scala.io.StdIn._
object
Main
{
var
continuer
=
true
def
main
(
args
:
Array
[
String
])
:
Unit
=
{
var
pincorrect
=
"INTRO1234"
var
pincorrect
=
Array
(
"a"
,
"b"
,
"c"
,
"d"
,
"e"
)
var
pin
=
""
var
continuer
=
true
var
montantinitial
=
1200.0
var
comptes
=
Array
(
montantinitial
,
montantinitial
,
montantinitial
,
montantinitial
,
montantinitial
)
var
nbclient
=
comptes
.
length
println
(
"nbclient"
+
nbclient
)
var
check
=
0
var
tentative
=
0
var
choixdevise1
=
"CHF"
var
choixdevise2
=
"EUR"
var
choix
=
0
var
depot
=
0
var
choix1
=
depot
var
consultation
=
0
var
choix2
=
consultation
var
montantdeposer
=
0
var
devise
=
0
var
retrait
=
0
var
choix3
=
retrait
var
montantderetrait
=
""
var
geossecoupures
=
0
var
petitesecoupures
=
0
var
coupures
=
0
var
montantderetraitEuro
=
0
var
montantautoriser
=
1080
var
montantautoriserEuro
=
0
var
montantdisponible
=
montantinitial
var
monID
=
0
println
(
"Saisissez votre code identifiant >"
)
monID
=
readLine
().
toInt
while
(
continuer
)
{
//afficher les operation
println
(
"Choisissez votre opération:"
)
println
(
"1. Dépôt"
)
println
(
"2. Consultation"
)
println
(
"3. Retrait"
)
println
(
"4. Terminer"
)
println
(
"Entrez le numéro de l'opération: "
)
choix
=
readLine
().
toInt
if
(
choix
==
1
||
choix
==
2
||
choix
==
3
||
choix
==
4
){
continuer
=
false
}
if
(
choix
==
4
){
println
(
"Fin des opérations.n'oubliez pas de récupérer votre carte."
)
}
while
(
monID
>
nbclient
){
println
(
"Cet identifiant n'est pas valable."
)
println
(
"Saisissez votre code identifiant >"
)
monID
=
readLine
().
toInt
if
(
choix
==
1
||
choix
==
2
||
choix
==
3
){
}
//demander a l'utilisateu le pin
println
(
"Saisissez votre code pin > "
)
pin
=
readLine
(
"quel est votre pin? >"
)
if
(
pin
==
pincorrect
){
if
(
pin
==
pincorrect
(
monID
-
1
)
){
//afficher les operation
//demander a l'utilisateu de choisir une operation
println
(
"Choisissez votre opération:"
)
println
(
"1. Dépôt"
)
println
(
"2. Consultation"
)
println
(
"3. Retrait"
)
println
(
"4. Terminer"
)
println
(
"Entrez le numéro de l'opération: "
)
choix
=
readLine
().
toInt
}
else
{
println
(
"Code correct !"
)
}
else
{
while
(
tentative
<
3
&&
pin
!=
pincorrect
)
{
println
(
"Il faut saisir un pin correct > "
)
pin
=
readLine
()
tentative
+=
1
println
(
"Code pin erroné, il vous reste "
+
tentative
+
" tentatives >"
)
}
}
if
(
tentative
==
3
&&
pin
!=
pincorrect
){
println
(
"Pour votre protection, les opérations bancaires vont s'interrompre, récupérez votre carte"
)
continuer
=
false
}
println
(
"Trop d'erreurs, abandon de l'identification"
)
}
while
(
continuer
){
//afficher les operation
println
(
"Choisissez votre opération:"
)
println
(
"1. Dépôt"
)
println
(
"2. Consultation"
)
println
(
"3. Retrait"
)
println
(
"4. Changement du pin"
)
println
(
"5. Terminer"
)
println
(
"Entrez le numéro de l'opération: "
)
choix
=
readLine
().
toInt
if
(
choix
==
1
){
continuer
=
true
while
(
continuer
){
println
(
"quelle est la devise: 1 pour CHF et 2 pour EUR? "
)
devise
=
readLine
().
toInt
if
(
devise
==
1
||
devise
==
2
){
println
(
"quelle est le montant a deposer?"
)
montantdeposer
=
readInt
()
if
(
montantdeposer
%
10
==
0
){
depot
(
monID
,
comptes
)
}
if
(
choix
==
2
)
{
printf
(
"la valeur de montantdisponible : %.2f \n"
,
comptes
(
monID
)
)}
if
(
choix
==
3
){
// si le client veut retirer de l'argent
retrait
(
monID
,
comptes
)
continuer
=
false
}
}
else
{
println
(
"Impossible"
)
if
(
choix
==
4
){
changepin
(
monID
,
pincorrect
)
}
if
(
choix
==
5
){
println
(
"Fin des opérations, n'oubliez pas de récupérer votre carte."
)
}
}
}
if
(
devise
!=
1
||
devise
!=
2
||
montantdeposer
%
10
!=
0
)
{
println
(
"operation impossible"
)
def
retrait
(
id
:
Int
,
comptes
:
Array
[
Double
])
:
Unit
={
var
devise
=
0
var
montantderetrait
=
0
var
coupures
=
0
var
correct
=
true
println
(
"quelle est la devise: 1 pour CHF et 2 pour EUR? "
)
devise
=
readLine
().
toInt
println
(
"quelle est le montant a retirer?"
)
montantderetrait
=
readLine
().
toInt
if
(
montantderetrait
%
10
==
0
){
if
(
devise
==
1
){
println
(
"choisissez la coupure: 1 pour petite et 2 pour grande"
)
coupures
=
readInt
()
}
comptes
(
id
)-=
montantderetrait
*
1.05
printf
(
"Votre retrait a été pris en compte, le nouveau montant disponible sur votre compte est : %.2f CHF\n"
,
comptes
(
id
))
if
(
devise
==
1
||
devise
==
2
){
if
(
devise
==
1
&&
montantdeposer
%
10
==
0
){
println
(
"operation reussie; "
+
"montantdisponible"
+
montantinitial
+
montantdeposer
)
}
}
else
{
println
(
"operation impossible"
)
}
if
(
devise
==
2
&&
montantdeposer
%
10
==
0
){
println
(
"montantdisponible "
+
montantinitial
+
0.95
*
montantdeposer
)
}
if
(
devise
!=
2
||
montantdeposer
%
10
!=
0
)
{
if
(
montantdeposer
%
10
!=
0
||
devise
!=
1
)
println
(
"operation impossible"
)
}
montantdisponible
=
montantinitial
+
montantdeposer
printf
(
"Votre depot a été pris en compte, le nouveau montant disponible sur votre compte est : %.2f CHF\n"
,
montantdisponible
)
}
else
{
println
(
"operation impossible"
)}
}
def
depot
(
id
:
Int
,
comptes
:
Array
[
Double
])
:
Unit
={
var
devise
=
0
var
montantdeposer
=
0
if
(
choix
==
2
)
{
printf
(
"la valeur de montantdisponible : %.2f \n"
,
montantdisponible
)
println
(
"quelle est la devise: 1 pour CHF et 2 pour EUR? "
)
devise
=
readInt
()
println
(
"quelle est le montant a deposer?"
)
montantdeposer
=
readInt
()
if
(
montantdeposer
%
10
==
0
){
if
(
devise
==
1
){
comptes
(
id
)
+=
montantdeposer
}
if
(
devise
==
2
){
comptes
(
id
)+=
0.95
*
montantdeposer
}
}
printf
(
"Votre depot a été pris en compte, le nouveau montant disponible sur votre compte est : %.2f CHF\n"
,
comptes
(
id
))
}
if
(
choix
==
4
){
println
(
"Fin des opérations.n'oubliez pas de récupérer votre carte."
)
}
def
changepin
(
id
:
Int
,
codespin
:
Array
[
String
])
:
Unit
={
var
newpin
=
""
printf
(
"Entrez votre nouveau pin"
)
codespin
(
id
-
1
)
=
readLine
()
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment