initial commit
This commit is contained in:
@@ -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,94 @@
|
||||
/*
|
||||
|
||||
Exercice 1
|
||||
|
||||
On donne l’algorithme suivant :
|
||||
|
||||
Variable : entier a
|
||||
entier b
|
||||
entier x
|
||||
entier y
|
||||
debut
|
||||
a=3
|
||||
b=4
|
||||
saisir x
|
||||
saisir y
|
||||
|
||||
si (x=a et y=b) alors
|
||||
debut de si
|
||||
afficher ("coulé")
|
||||
fin de si
|
||||
sinon
|
||||
debut de si
|
||||
affiche ("à l'eau")
|
||||
fin de sinon
|
||||
fin
|
||||
fin
|
||||
|
||||
a) Modifier l’algorithme afin que si une seule des coordonnées est correcte, il s’affiche « es un TDM
|
||||
|
||||
Variable :
|
||||
entier a
|
||||
entier b
|
||||
entier x
|
||||
entier y
|
||||
debut
|
||||
a=3
|
||||
b=4
|
||||
saisir x
|
||||
saisir y
|
||||
|
||||
si (x=a et y=b) alors
|
||||
debut de si
|
||||
afficher ("coulé")
|
||||
fin de si
|
||||
sinon si (x=a || y=b) alors
|
||||
debur de si
|
||||
affiche ("TDM")
|
||||
fin de si
|
||||
sinon
|
||||
debut de si
|
||||
affiche ("à l'eau")
|
||||
fin de sinon
|
||||
fin
|
||||
fin
|
||||
|
||||
b) Ecrire le programme correspondant en java.
|
||||
*/
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
public class App {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
// instantation des 4 variables :
|
||||
|
||||
int a = 3;
|
||||
int b = 4;
|
||||
|
||||
Scanner scannerX = new Scanner(System.in);
|
||||
System.out.print("Ecrire le nombre x: ");
|
||||
int x = scannerX.nextInt();
|
||||
Scanner scannerY = new Scanner(System.in);
|
||||
System.out.print("Ecrire le nombre y: ");
|
||||
int y = scannerY.nextInt();
|
||||
|
||||
// Première condition : Si 'x' est strictement égale à 'a' ET que 'y' est strictement égale à 'b'
|
||||
if(x == a && y == b){
|
||||
// alors on "affiche coulé"
|
||||
System.out.println("coulé");
|
||||
}
|
||||
// Deuxième condition : Sinon Si 'x' est strictemment égale à 'a' OU 'y' est strictement égale à 'b'
|
||||
else if(x == a || y == b){
|
||||
// alors on affiche "TDM"
|
||||
System.out.println("TDM");
|
||||
}
|
||||
// Sinon on affiche "à l'eau"
|
||||
else{
|
||||
System.out.println("à l'eau");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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,30 @@
|
||||
/*
|
||||
|
||||
Exercice 2 :
|
||||
|
||||
a) Ecrire un programme en java qui prend en entrée trois réels x, y et z et affiche le maximum des trois.
|
||||
|
||||
*/
|
||||
|
||||
public class App {
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
// instantiation de x, y et z
|
||||
|
||||
int x = 3;
|
||||
int y = 4;
|
||||
int z = 1;
|
||||
|
||||
if (x > y && x > z) {
|
||||
System.out.println("x est plus grand");
|
||||
}
|
||||
else if(y > x && y > z){
|
||||
System.out.println("y est plus grand");
|
||||
}
|
||||
else if(z > x && z > y){
|
||||
System.out.println("z est plus grand");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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,48 @@
|
||||
/*
|
||||
Exercice 3 :
|
||||
|
||||
Ecrire un programme qui, étant donné une équation du second degré,
|
||||
détermine le nombre de ses solutions réelles et leurs valeurs approchées éventuelles.
|
||||
|
||||
*/
|
||||
|
||||
public class App {
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
int a =1;
|
||||
int b =2;
|
||||
int c =1;
|
||||
|
||||
int delta = (b*b)-(4*a*c);
|
||||
|
||||
if (delta < 0) {
|
||||
System.out.println("L'équation admet aucune solution dans R");
|
||||
}
|
||||
else if(delta == 0){
|
||||
System.out.println("L'équation admet 1 solution dans R ");
|
||||
}
|
||||
else if(delta > 0){
|
||||
System.out.println("L'équation admet 2 solution dans R");
|
||||
}
|
||||
else{
|
||||
System.out.println("Une erreur est survenu");
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
||||
D = b² - 4ac
|
||||
|
||||
D > 0
|
||||
D = 0
|
||||
D < 0
|
||||
|
||||
ax² + bx + c
|
||||
|
||||
b² - 4ac
|
||||
|
||||
*/
|
||||
@@ -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,91 @@
|
||||
public class App {
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
// // Exemple 1 : If noramle (cette exemple n'est pas logique car le calcul s'effectu avant la vérification)
|
||||
|
||||
// int a = 6; // Déclaration
|
||||
// int b = 2; // |
|
||||
|
||||
// if(b == 0){ // Traitement
|
||||
// System.out.println("Division par 0 impossible !"); // |
|
||||
// } // |
|
||||
// System.out.println("Résultat est = "+ c); // |
|
||||
|
||||
// Exemple 2 : If Else
|
||||
|
||||
// int a = 6;
|
||||
|
||||
// if(a >= 10){
|
||||
// System.out.println("Vous avez plus de la moyenne : " + a);
|
||||
// }
|
||||
// else{
|
||||
// System.out.println("Vous passez au rattrapage car vous avez moins de 10");
|
||||
// }
|
||||
|
||||
// Exemple 3 : If Else If
|
||||
|
||||
// La Bonne Pratique :
|
||||
|
||||
// int note = 12;
|
||||
|
||||
// if(note > 18){
|
||||
// System.out.println("A");
|
||||
// }
|
||||
// else if(note > 16 && note <= 18){
|
||||
// System.out.println("B");
|
||||
// }
|
||||
// else if(note > 14 && note <= 16){
|
||||
// System.out.println("C");
|
||||
// }
|
||||
// else if(note > 12 && note <= 14){
|
||||
// System.out.println("D");
|
||||
// }
|
||||
// else{
|
||||
// System.out.println("F");
|
||||
// }
|
||||
|
||||
// Exemple 4 : Switch Case
|
||||
|
||||
// char sexe = 'F';
|
||||
|
||||
// switch (sexe) {
|
||||
// case 'F':
|
||||
// System.out.println("Il s'agit d'une femme");
|
||||
// break;
|
||||
// case 'H':
|
||||
// System.out.println("Il s'agit d'un homme");
|
||||
// break;
|
||||
// default:
|
||||
// System.out.println("Sexe indéterminé");
|
||||
// break;
|
||||
// }
|
||||
|
||||
// Exercice Switch :
|
||||
|
||||
// int taille = 34;
|
||||
|
||||
// switch (taille) {
|
||||
// case 34:
|
||||
// System.out.println("XS");
|
||||
// break;
|
||||
// case 36:
|
||||
// System.out.println("S");
|
||||
// break;
|
||||
// case 38:
|
||||
// System.out.println("SM");
|
||||
// break;
|
||||
// case 40:
|
||||
// System.out.println("M");
|
||||
// break;
|
||||
// case 42:
|
||||
// System.out.println("L");
|
||||
// break;
|
||||
// default:
|
||||
// System.out.println("La taille n'existe pas");
|
||||
// break;
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user