Yo tout le monde, j'ai un exercice qui me bloque depuis un moment, en faite j’ai réussi a faire le code mais je ne suis pas trop sur qu'il soit correcte. Donc j’espère que vous pourrez m'aider, merci d'avance. Voici le code
public class ComputerPersonStats {
public ComputerPersonStats() { }
public static void main (String[]args) {
int n = 1;
int nbFem = 0;
int nbHom = 0;
String firstName = "";
String lastName = "";
String Sex = "";
int Age = 0;
Scanner myScan = new Scanner (System.in);
while ( n <= 15) {
System.out.println ("Enter the person's first name please");
firstName = myScan.next();
System.out.println ("Enter the person's last name please");
lastName = myScan.next();
System.out.println ("the person's fullname is : " + firstName+ " " + lastName);
System.out.println ("Enter the person age in years please");
Age = myScan.nextInt();
System.out.println ("the age is : " + Age + " years old");
System.out.println ("Enter the sex of the person please");
Sex = myScan.next();
if (Sex.equals ("f")) {
System.out.println ("the person is a women");
nbFem ++; }
if (Sex.equals ("m")) {
System.out.println ("the person is a men");
nbHom ++;
}
}
System.out.println ("There are " + nbHom + " men and " + nbFem + " women");
}
}