Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace TP01_Partie01
- {
- class Program
- {
- static void Main(string[] args)
- {
- // tableau de nom, prenom tel
- string[] tabNoms = new string[10];
- string[] tabPrenoms = new string[10];
- string[] tabTelephones = new string[10];
- // initialisation du nombre de client
- int nbreClient = 0;
- string nom, prenom, telephone;
- string part1, part2, part3, part4, part5, part6, part7;
- Console.WriteLine("Entrer le nombre de client");
- try
- {
- nbreClient = int.Parse(Console.ReadLine());
- }
- catch
- {
- Console.WriteLine("Introduire un nombre!");
- }
- int cnt = 0;
- while (cnt < nbreClient)
- {
- Console.WriteLine("Entrer le nom du client");
- nom = Console.ReadLine();
- tabNoms[cnt] = nom;
- Console.WriteLine("Entrer le prenom du client");
- prenom = Console.ReadLine();
- tabPrenoms[cnt] = prenom;
- //------------------------------------- Saisi du Numero de telephone -------------------------------------
- string TelephoneTest = "";
- bool isValid = true;
- while (true)
- {
- Console.WriteLine("Entrer le telephone du client sous cette forme (555) 555-5555");
- TelephoneTest = Console.ReadLine();
- if (TelephoneTest == "")
- {
- Console.WriteLine("\n" + "- Veuillez svp entrer un numero de telephone!" + "\n");
- isValid = false;
- }
- else
- if (TelephoneTest.Length != 14)
- {
- Console.WriteLine("- Le numero doit avoir 14 caracteres!");
- isValid = false;
- }
- else
- {
- part1 = TelephoneTest.Substring(0, 1);
- part2 = TelephoneTest.Substring(1, 3);
- part3 = TelephoneTest.Substring(4, 1);
- part4 = TelephoneTest.Substring(5, 1);
- part5 = TelephoneTest.Substring(6, 3);
- part6 = TelephoneTest.Substring(9, 1);
- part7 = TelephoneTest.Substring(10, 4);
- int val;
- if (part1 != "(")
- {
- isValid = false;
- Console.WriteLine("Vous devez utiliser des prentheses!");
- }
- else if (!int.TryParse(part2, out val) || !int.TryParse(part5, out val)
- || !int.TryParse(part7, out val))
- {
- isValid = false;
- Console.WriteLine("Vous devez utiliser des chiffres!");
- }
- else if ((part3 != ")") || (part4 != " "))
- {
- isValid = false;
- Console.WriteLine("Vous devez utiliser des prentheses et un espace!");
- }
- }
- if (isValid)
- {
- break;
- }
- }
- telephone = TelephoneTest;
- tabTelephones[cnt] = telephone;
- //------------------------------------- Fin de du Numero de telephone -------------------------------------
- cnt++;
- }
- int j = 1;
- for (int i = 0 ; i < nbreClient; i++,j=i+1)
- {
- Console.WriteLine("le nom du client numero " + j + " est " + tabNoms[i]);
- Console.WriteLine("le prenom du client numero " + j + " est " + tabPrenoms[i]);
- Console.WriteLine("le telephone du client numero " + j + " est " + tabTelephones[i]);
- }
- Console.ReadKey();
- }
- }
- }
Add Comment
Please, Sign In to add comment