Skip to content
Snippets Groups Projects
Commit aeec1ef4 authored by mathias.catala's avatar mathias.catala
Browse files

"adding bancomat"

parent bac6e98b
No related branches found
No related tags found
No related merge requests found
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment