code routier francais essai en linge code example
Example 1: java d'intervalle de resultat
public class Program
{
static Scanner scanne = new Scanner(System.in);
public static ArrayList<Article> articles = new ArrayList();
public static void main(String[] args)
{
do{
System.out.println("\n----------------------------------------\n"
+ "Bienvenue dans l'intervalle de prix\n"
+ "----------------------------------------\n");
System.out.print("Veuillez saisir un prix minimum\n> ");
int prixMin = scanne.nextInt();
System.out.println("Veuillez saisir un prix maximum\n> ");
int prixMax = scanne.nextInt();
Program.searchByIntervalle(prixMin, prixMax);
System.out.print("\nVoulez-vous continuer le programme ?(oui/non)\n> ");
repBoucle = scanne.next();
if (repBoucle.equals("oui"))
{
boucle = true;
}
System.out.println("\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
} while (boucle == true)
}
protected static void searchByIntervalle(int prixMin, int prixMax) {
articles.forEach((article) -> {
if (prixMin >= 0 && prixMax <= 6000) {
System.out.println("\nArticle correspondant à votre recherche :");
System.out.println(" - Id : " + article.getId());
System.out.println(" - Nom : " + article.getName());
System.out.println(" - Prix : " + article.getPrix());
System.out.println(" - Stock : " + article.getStock());
} else {
System.err.println("----------------------------------------\n"
+ "Aucun article trouvé !\n"
+ "----------------------------------------");
}
});
}
}
public class Article {
private int id;
private String name;
private int prix;
private int stock;
public Article(int id, String name, int prix, int stock) {
this.id = id;
this.name = name;
this.prix = prix;
this.stock = stock;
}
protected int getId() {
return this.id;
}
protected void setId(int id) {
this.id = id;
}
protected String getName() {
return this.name;
}
protected void setName(String name) {
this.name = name;
}
protected int getPrix() {
return this.prix;
}
protected void setPrix(int prix) {
this.prix = prix;
}
protected int getStock() {
return this.stock;
}
protected void setStock(int stock) {
this.stock = stock;
}
}
Example 2: en c code pour affichage
#include <iostream>
int main()
{
std::cout << "Hello world!" << std::endl;
return 0;
}