0
I need that if none of the conditions’S',’s','N','n' is entered by the user the program keeps asking "Do you want to continue running? (S/N):"
public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    DecimalFormat formatador = new DecimalFormat("0.00");
    Double precobruto,desconto,precoavista; 
    int numex;
    char opcao;
    System.out.print("Informe a quantidade de produtos:");
    numex = sc.nextInt();
    for(int i=0; i<=numex; i++){
    System.out.println("Insira o valor do produto:");   
    precobruto = sc.nextDouble();
    desconto = (precobruto*0.1);
    precoavista = precobruto - desconto;
    System.out.println("Preço bruto: "+formatador.format(precobruto));
    System.out.println("Preço a vista: "+formatador.format(precoavista));
    System.out.println("Desconto (10%): "+formatador.format(desconto));
    System.out.print("\n");
    System.out.println("Deseja continuar a execução?(S/N):");
    opcao = sc.next().charAt(0);
    if (opcao == 'n' || opcao == 'N'){
    System.exit(0);
}
    if (opcao == 's' || opcao == 'S'){
    continue;
}
    else{
    System.out.println("Deseja continuar a execução?(S/N):");
}
        }
    }
do... whileis the solution– user28595
You can optimize this code, but for that, you need to explain what you want with this code first.
– user28595