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 Test3
{
public static void main(String[] args)
{
String prenom = new String();
char car = ' ';
Scanner sc = new Scanner(System.in);
while (car == 'y');
{
do
{
System.out.print("Donnez un prénom : ");
prenom = sc.nextLine();
System.out.println("Bonjour " +prenom+ ", comment vas-tu ?");
System.out.println("Voulez-vous réessayer ?(y/n)");
car = sc.nextLine().charAt(0);
}while(car == 'y');
}
System.out.println("Au revoir...");
}
} |
Partager