initial commit

This commit is contained in:
Guillaume-Sanchez
2026-05-26 13:56:03 +02:00
parent 4c720637a1
commit ff4bb12d22
539 changed files with 12415 additions and 0 deletions
+103
View File
@@ -0,0 +1,103 @@
# UTC 503 du 16/12/2024
## Les instructions :
### Les boucles
Répéter un traintement plusieurs fois
Une boule n'est utile que si on peut la controler -> éviter les boucle infini
plusieurs façon de les réaliser :
***for*** -> Pour i = 0; tant que i est inférieur à 5; ajouter 1 à i :
```
for (int i=0;i>5;i=i+1){
Système.out.println("****");
}
```
Cette exemple affichera 5 fois "****"
***while*** -> Tant que,
On boucle "tant que" la condition est celle demandé :
```
// instancie "reponse" par le caractère "O"
char reponse = 'O';
// Tant que reponse est égale et de même type que le caractère "O" :
while (reponse == 'O') {
// affiche la phrase :
System.out.println("veuiller saisir un prenom : ");
// scanner pour récupérer la valeur par l'utilisateur :
String prenom = sc.nextLine();
// Affiche "Bonjour" suivi de la saisi de l'utilisateur :
System.out.println("Bonjour, " + prenom);
// Affiche la pharse pour asvoir si on recommance :
System.out.println("voulez-vous réessayer ? (O/N) ");
// On récupère le premier caractère de la valeur saisi et on instanci reponse avec.
reponse = sc.nextLine().charAt(0);
}
// Si reponse = O, alors on rejout, sinon, on affiche :
System.out.println("Au revoir");
```
***Do while*** -> Faire, Tant que
Les instructions vont au moins s'executer une fois
(Même code qu'en dessous, mais )
```
char reponse = 'O';
do{
System.out.println("veuiller saisir un prenom : ");
String prenom = sc.nextLine();
System.out.println("Bonjour, " + prenom);
System.out.println("voulez-vous réessayer ? (O/N) ");
reponse = sc.nextLine().charAt(0);
} while (reponse == 'O');
System.out.println("A+");
```
### Scanner :
Pour qu'un utilisateur puissent saisire des caractères, on utilise la class Scanner, avec sa méthode nextLine exemple :
```
Scanner sc = new Scanner(System.in);
System.out.println("veuiller saisir un mot : ");
String str = sc.nextLine();
System.out.println("Vous avez saisi : " + str);
```
"Scanner sc" c'est la class, new Scanner(System.in) c'est l'utilisation du constructeur
### /!\ Décomposition d'une fonction Système :
(Demmandé en examen)
```
System.out.println("...")
| | |------> Methode
| |-----------> Objet
|-----------------> Class
```
+158
View File
@@ -0,0 +1,158 @@
# TD2-Boucle
>Guillaume Sanchez
## Exercice 1
écrire un programme affichant la table de multiclication d'un nombre saisi par l'utilisateur
```
import java.util.Scanner;
public class App {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
System.out.print("Entrez le chiffre que vous voulez : ");
int num = sc.nextInt();
for(int i = 1; i <= 10; i++ ){
System.out.println(num + " x " + i + " = " + num*i);
}
}
}
```
Le résultat de ce code :
```
Entrez le chiffre que vous voulez : 3
3 x 1 = 3
3 x 2 = 6
3 x 3 = 9
3 x 4 = 12
3 x 5 = 15
3 x 6 = 18
3 x 7 = 21
3 x 8 = 24
3 x 9 = 27
3 x 10 = 30
```
## Exercice 2
Écrire un programme affichant les tables de multiplications des nombres de 1 à 10 dans un tableau à deux entrées.
```
public class App {
public static void main(String[] args) throws Exception {
for(int a=1; a<=10; a++){
System.out.print(a + " : ");
for(int b=1; b<=10;b++){
System.out.print(a*b + ", " );
}
System.out.println();
}
}
}
```
Le résultat de ce code :
```
1 : 1 2 3 4 5 6 7 8 9 10
2 : 2 4 6 8 10 12 14 16 18 20
3 : 3 6 9 12 15 18 21 24 27 30
4 : 4 8 12 16 20 24 28 32 36 40
5 : 5 10 15 20 25 30 35 40 45 50
6 : 6 12 18 24 30 36 42 48 54 60
7 : 7 14 21 28 35 42 49 56 63 70
8 : 8 16 24 32 40 48 56 64 72 80
9 : 9 18 27 36 45 54 63 72 81 90
10 : 10 20 30 40 50 60 70 80 90 100
```
## Exercice 3
Écrire un programme demandant à lutilisateur de saisir deux valeurs numériques b et n (vérifier que n est positif) et affichant la valeur bn.
```
public class App {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
System.out.print("Entrez le premier chiffre que vous voulez (b) : ");
int b = sc.nextInt();
int n;
do{
System.out.print("Entrez le second chiffre que vous voulez (n), il doit être positif : ");
n = sc.nextInt();
// Vérification à effectuer pour savoir si "n" est positif, sinon on repart au "do"
} while (n < 0);
System.out.println(b + " * " + n + " = " + b*n);
}
}
```
Le résultat de ce code dans le cas ou "n" est positif :
```
Entrez le premier chiffre que vous voulez (b) : 3
Entrez le second chiffre que vous voulez (n), il doit être positif : 4
3 * 4 = 12
```
Le résultat de ce code dans le cas ou "n" est négatif, le programme revient au choix de "n" :
```
Entrez le premier chiffre que vous voulez (b) : 6
Entrez le second chiffre que vous voulez (n), il doit être positif : -6
Entrez le second chiffre que vous voulez (n), il doit être positif : 6
6 * 6 = 36
```
## Exercice 4
Ecrire un programme demandant la saisi d'une valeur `n` et affichant le carré suivant (n = 5 dans cette exemple):
xxxxx
xxxxx
xxxxx
xxxxx
xxxxx
```
import java.util.Scanner;
public class App {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
System.out.print("Entrez le chiffre que vous voulez : ");
int num = sc.nextInt();
for(int x = 1; x <= num; x++){
for(int y = 1; y <= num ; y++){
System.out.print('x');
}
System.out.println();
}
}
}
```
Le résultat de ce code :
```
Entrez le chiffre que vous voulez : 3
xxx
xxx
xxx
```
Binary file not shown.
+136
View File
@@ -0,0 +1,136 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TD2-Boucles.md</title>
<link rel="stylesheet" href="https://stackedit.io/style.css" />
</head>
<body class="stackedit">
<div class="stackedit__html"><h1 id="td2-boucle">TD2-Boucle</h1>
<blockquote>
<p>Guillaume Sanchez</p>
</blockquote>
<h2 id="exercice-1">Exercice 1</h2>
<p>écrire un programme affichant la table de multiplication dun nombre saisi par lutilisateur</p>
<pre><code>import java.util.Scanner;
public class App {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
System.out.print("Entrez le chiffre que vous voulez : ");
int num = sc.nextInt();
for(int i = 1; i &lt;= 10; i++ ){
System.out.println(num + " x " + i + " = " + num*i);
}
}
}
</code></pre>
<p>Le résultat de ce code :</p>
<pre><code>Entrez le chiffre que vous voulez : 3
3 x 1 = 3
3 x 2 = 6
3 x 3 = 9
3 x 4 = 12
3 x 5 = 15
3 x 6 = 18
3 x 7 = 21
3 x 8 = 24
3 x 9 = 27
3 x 10 = 30
</code></pre>
<h2 id="exercice-2">Exercice 2</h2>
<p>Écrire un programme affichant les tables de multiplications des nombres de 1 à 10 dans un tableau à deux entrées.</p>
<pre><code>public class App {
public static void main(String[] args) throws Exception {
for(int a=1; a&lt;=10; a++){
System.out.print(a + " : ");
for(int b=1; b&lt;=10;b++){
System.out.print(a*b + ", " );
}
System.out.println();
}
}
}
</code></pre>
<p>Le résultat de ce code :</p>
<pre><code>1 : 1 2 3 4 5 6 7 8 9 10
2 : 2 4 6 8 10 12 14 16 18 20
3 : 3 6 9 12 15 18 21 24 27 30
4 : 4 8 12 16 20 24 28 32 36 40
5 : 5 10 15 20 25 30 35 40 45 50
6 : 6 12 18 24 30 36 42 48 54 60
7 : 7 14 21 28 35 42 49 56 63 70
8 : 8 16 24 32 40 48 56 64 72 80
9 : 9 18 27 36 45 54 63 72 81 90
10 : 10 20 30 40 50 60 70 80 90 100
</code></pre>
<h2 id="exercice-3">Exercice 3</h2>
<p>Écrire un programme demandant à lutilisateur de saisir deux valeurs numériques b et n (vérifier que n est positif) et affichant la valeur bn.</p>
<pre><code>import java.util.Scanner;
public class App {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
System.out.print("Entrez le premier chiffre que vous voulez (b) : ");
int b = sc.nextInt();
int n;
do{
System.out.print("Entrez le second chiffre que vous
voulez (n), il doit être positif : ");
n = sc.nextInt();
} while (n &lt; 0);
System.out.println(b + " * " + n + " = " + b*n);
}
}
</code></pre>
<p>Le résultat de ce code dans le cas ou “n” est positif :</p>
<pre><code>Entrez le premier chiffre que vous voulez (b) : 3
Entrez le second chiffre que vous voulez (n), il doit être positif : 4
3 * 4 = 12
</code></pre>
<p>Le résultat de ce code dans le cas ou “n” est négatif, le programme revient au choix de “n” :</p>
<pre><code>Entrez le premier chiffre que vous voulez (b) : 6
Entrez le second chiffre que vous voulez (n), il doit être positif : -6
Entrez le second chiffre que vous voulez (n), il doit être positif : 6
6 * 6 = 36
</code></pre>
<h2 id="exercice-4">Exercice 4</h2>
<p>Ecrire un programme demandant la saisi dune valeur <code>n</code> et affichant le carré suivant (n = 5 dans cette exemple):<br>
xxxxx<br>
xxxxx<br>
xxxxx<br>
xxxxx<br>
xxxxx</p>
<pre><code>import java.util.Scanner;
public class App {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
System.out.print("Entrez le chiffre que vous voulez : ");
int num = sc.nextInt();
for(int x = 1; x &lt;= num; x++){
for(int y = 1; y &lt;= num ; y++){
System.out.print('x');
}
System.out.println();
}
}
}
</code></pre>
<p>Le résultat de ce code :</p>
<pre><code>Entrez le chiffre que vous voulez : 3
xxx
xxx
xxx
</code></pre>
</div>
</body>
</html>
Binary file not shown.
+18
View File
@@ -0,0 +1,18 @@
## Getting Started
Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code.
## Folder Structure
The workspace contains two folders by default, where:
- `src`: the folder to maintain sources
- `lib`: the folder to maintain dependencies
Meanwhile, the compiled output files will be generated in the `bin` folder by default.
> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there.
## Dependency Management
The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies).
Binary file not shown.
+46
View File
@@ -0,0 +1,46 @@
import java.util.Scanner;
public class App {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
// for(int i = 0; i < 5; i = i + 1){
// System.out.println("**** " + i);
// }
// System.out.println("veuiller saisir un mot : ");
// String str = sc.nextLine();
// System.out.println("Vous avez saisi : " + str);
// int a = 1; int b = 15;
// while (a < b){
// System.out.println("coucou " + a + " " + b);
// a++;
// }
// char reponse = 'O';
// while (reponse == 'O') {
// System.out.println("veuiller saisir un prenom : ");
// String prenom = sc.nextLine();
// System.out.println("Bonjour, " + prenom);
// System.out.println("voulez-vous réessayer ? (O/N) ");
// reponse = sc.nextLine().charAt(0);
// }
// System.out.println("A+");
char reponse = 'O';
do{
System.out.println("veuiller saisir un prenom : ");
String prenom = sc.nextLine();
System.out.println("Bonjour, " + prenom);
System.out.println("voulez-vous réessayer ? (O/N) ");
reponse = sc.nextLine().charAt(0);
} while (reponse == 'O');
System.out.println("A+");
}
}
+18
View File
@@ -0,0 +1,18 @@
## Getting Started
Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code.
## Folder Structure
The workspace contains two folders by default, where:
- `src`: the folder to maintain sources
- `lib`: the folder to maintain dependencies
Meanwhile, the compiled output files will be generated in the `bin` folder by default.
> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there.
## Dependency Management
The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies).
Binary file not shown.
@@ -0,0 +1,17 @@
// Exercice 1 :
// écrire un programme affichant la table de multiclication d'un nombre saisi par l'utilisateur
import java.util.Scanner;
public class App {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
System.out.println("Entrez le chiffre que vous voulez :");
int num = sc.nextInt();
for(int i = 1; i <= 10; i++ ){
System.out.println(num + " x " + i + " = " + num*i);
}
}
}
+18
View File
@@ -0,0 +1,18 @@
## Getting Started
Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code.
## Folder Structure
The workspace contains two folders by default, where:
- `src`: the folder to maintain sources
- `lib`: the folder to maintain dependencies
Meanwhile, the compiled output files will be generated in the `bin` folder by default.
> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there.
## Dependency Management
The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies).
Binary file not shown.
@@ -0,0 +1,14 @@
// Écrire un programme affichant les tables de multiplications des nombres de 1 à 10 dans un tableau à deux entrées.
public class App {
public static void main(String[] args) throws Exception {
for(int a=1; a<=10; a++){
System.out.print(a + " : ");
for(int b=1; b<=10;b++){
System.out.print(a*b + " " );
}
System.out.println();
}
}
}
+18
View File
@@ -0,0 +1,18 @@
## Getting Started
Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code.
## Folder Structure
The workspace contains two folders by default, where:
- `src`: the folder to maintain sources
- `lib`: the folder to maintain dependencies
Meanwhile, the compiled output files will be generated in the `bin` folder by default.
> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there.
## Dependency Management
The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies).
Binary file not shown.
@@ -0,0 +1,21 @@
// Écrire un programme demandant à lutilisateur de saisir deux valeurs numériques b et n (vérifier que n est positif) et affichant la valeur bn.
import java.util.Scanner;
public class App {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
System.out.print("Entrez le premier chiffre que vous voulez (b) : ");
int b = sc.nextInt();
int n;
do{
System.out.print("Entrez le second chiffre que vous voulez (n), il doit être positif : ");
n = sc.nextInt();
// Vérification à effectuer pour savoir si "n" est positif, sinon on repart au "do"
} while (n < 0);
System.out.println(b + " * " + n + " = " + b*n);
}
}
+18
View File
@@ -0,0 +1,18 @@
## Getting Started
Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code.
## Folder Structure
The workspace contains two folders by default, where:
- `src`: the folder to maintain sources
- `lib`: the folder to maintain dependencies
Meanwhile, the compiled output files will be generated in the `bin` folder by default.
> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there.
## Dependency Management
The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies).
Binary file not shown.
@@ -0,0 +1,29 @@
// Ecrire un programme demandant la saisi d'une valeur `n` et afficahnt le carré suivant (n = 5 dans cette exemple):
// xxxxx
// xxxxx
// xxxxx
// xxxxx
// xxxxx
import java.util.Scanner;
public class App {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
System.out.print("Entrez le chiffre que vous voulez : ");
int num = sc.nextInt();
for(int x = 1; x <= num; x++){
for(int y = 1; y <= num ; y++){
System.out.print('x');
}
System.out.println();
}
}
}