4
I’m a beginner and I’m having second thoughts While / Do…While, follows the doubt in which question.
I have an exercise to follow that the teacher solved with the command Do…While, I was trying to do with the while to exercise and found myself totally dead-end.
Create A program to validate the following information.
nome > 3 caracteres idade > 0 e idade < 150 salario > 0 sexo ' f ' ou ' m ' estado civil 's' 'c' 'v' 'd'
    public class Exercicios3 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        boolean validaCampo = true;
        System.out.println("Nome: ");
        String nome = sc.nextLine();
        System.out.println("Idade: ");
        int idade = sc.nextInt();
        System.out.println("Salário: ");
        double salario = sc.nextDouble();
        System.out.println("Sexo: ");
        char sexo = sc.next().charAt(0);
        System.out.println("Estado Civil: ");
        char estadoCivil = sc.next().charAt(0);
        while (!validaCampo) {
            if (nome.length() < 3) {
                validaCampo = false;
                System.out.println("Nome muito pequeno, digite novamente ");
                nome = sc.nextLine();
            } else if (idade <= 0 && idade > 150) {
                validaCampo = false;
                System.out.println("Idade maior que 0 e menor que 105, digite novamente ");
                idade = sc.nextInt();
            } else if (salario < 0) {
                validaCampo = false;
                System.out.println("Salario tem que ser maior que 0, digite novamente ");
                salario = sc.nextDouble();
            } else if (sexo != 'M' || sexo != 'F') {
                validaCampo = false;
                System.out.println("Caracteres têm que ser M - Masculino e F - Feminino, digite novamente ");
                sexo = sc.next().charAt(0);
            } else if ((estadoCivil != 's') || (estadoCivil != 'c') || (estadoCivil != 'v') || (estadoCivil != 'd')) {
                validaCampo = false;
                System.out.println("Caracteres têm que ser s , c , v ou d, digite novamente");
                estadoCivil = sc.next().charAt(0);
            }
            System.out.println("\nFlag ValidaCampo:" + validaCampo);
            System.out.println("\nNome:" + nome);
            System.out.println("Idade:" + idade);
            System.out.println("Salário:" + salario);
            System.out.println("Gênero:" + sexo);
            System.out.println("Estado Civil:" + estadoCivil);
            sc.close();
        }
    }
}
						
What was the expected output and which output you got?
– Lucas Duete