salut,j'ai besoin de votre aide pour une petite application de gestion client qui fait trois options:Enregister/Modifier/Chercher/Supprimer.
Bon l'erreur apparait dans les case 2,3,4 pour les tableaux:t1.length et t2.length.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144 import java.util.Arrays; import java.util.Scanner; import java.lang.String; public class Gestion_Client { public static void main(String[] args){ Scanner lire=new Scanner(System.in); String reponse=""; while(!reponse.equals("non"));{ System.out.println("VOULEZ-VOUS:"); System.out.println ("************Menu*************"); System.out.println ("|1--------------> Enregister"); System.out.println ("|2--------------> Modifier"); System.out.println ("|3--------------> Chercher"); System.out.println ("|4--------------> Supprimer"); System.out.println ("******************************"); System.out.print ("Entrez votre choix: "); int choix=lire.nextInt(); String[] copie ; int nc; int[] copie1; String []t1; int []t2; switch (choix) { case 1 : { System.out.println("Combien de client voulez-vs ENREGISTRER:"); int x=lire.nextInt(); t1=new String[x]; t2=new int[x]; for(int i=0;i<t1.length;i++){ for(int j=0;j<t2.length;j++){ System.out.println("Entrer le nom/prénom du client suivant l'exemple:Satri jihad"); t1[i]=lire.next(); copie = new String[t1.length]; System.arraycopy(t1, 0, copie, 0, t1.length); final List a = Arrays.asList(copie); System.out.println("Entrer son numéro de compte:"); t2[j]=lire.nextInt(); copie1 = new int[t2.length]; System.arraycopy(t2, 0, copie1, 0, t2.length); } } System.out.println("Le client a était bien ENREGISTRER"); break; } case 2:{ System.out.println("Entrer le numéro de compte du client à MODIFIER:"); nc=lire.nextInt(); copie = new String[t1.length]; copie1 = new int[t2.length]; for(int i=0;i<copie.length;i++){ for(int j=0;j<copie1.length;j++){ if(copie1[j]==nc){ System.out.println("Le nom/prénom du client est:"+copie[i]+"et son n°de compte:"+copie1[j]); System.out.println("Voulez-vous MODIFIER le nom/prénom du client et son compte??"); String rep=lire.next(); if(rep.equals("oui")){ System.out.println("Entrez le nouveau nom/prénom:"); String repn=lire.next(); System.out.println("Entrez le nouveau n°de compte:"); int newc=lire.nextInt(); copie[i]=repn; copie1[j]=newc; } } else { System.out.println("Le n° de compte du client n'existe pas");} }} break; } case 3 :{ System.out.println("Entrer le n° de compte du client à CHERCHER:"); nc=lire.nextInt(); copie = new String[t1.length]; copie1 = new int[t2.length]; for(int i=0;i<copie.length;i++){ for(int j=0;j<copie1.length;j++){ if(copie1[j]==nc){ System.out.println("Le nom/prénom du client est:"+copie[i]+"et son n°de compte:"+copie1[j]); } else { System.out.println("Ce client n'existe pas"); } }} break; } case 4 :{ System.out.println("Entrer le n° de compte du client à SUPPRIMER:"); nc=lire.nextInt(); copie = new String[t1.length]; copie1 = new int[t2.length]; for(int i=0;i<copie.length;i++){ for(int j=0;j<copie1.length;j++){ if(copie1[j]==nc){ copie[i]=""; copie1[j]=0; } }} System.out.println("Ce client a était bien SUPPRIMER"); break; } default: System.out.println("ERREUR!!!Vs-devez choisir un nombre 1<n<4."); } System.out.println("Voulez-vous continuer??Tapez oui pour continuer et autres pour sortir"); reponse=lire.next(); } }}
il faut les initialisé mais chose que je l'ai deja fait dans case1 et c'est la seule initialisation qu'ils peuvent avoir,enfin je sais pas vraiment comment faire??
Partager