1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| import java.util.Scanner;
public class Chaine {
public static void main(String[] args) {
// TODO Auto-generated method stub
String chain = "il fait beau aujourd'hui ";
Scanner scan = new Scanner(System.in);
System.out.println("quel mots chercher vous ?");
String mot = scan.nextLine();
if ( chain.contains(mot)) {
System.out.println("trouver");
chain = chain.replace(mot,"");
}
else {
System.out.println("introuvable");
}
System.out.println("par quel mots voulez vous le remplacer?");
String mot2 = scan.nextLine();
mot = mot2;
System.out.println(chain);
}
} |
Partager