I made a code to apply different kinds of discounts to people asking age, genre and if their parent is partner or not. I checked several times and even its a very simple code I cant see where is the problem. Thanks to all of you that answer my threat.
I already tried clearing buffer but nothing changes...
public static void calculoDescuento() {
float cuota=500;
float descuento;
int edad;
String sexo;
String padreSocio;
Scanner sc=new Scanner(System.in);
Scanner in=new Scanner(System.in);
//asking for the age
System.out.println("Escriba su edad: ");
edad=sc.nextInt();
if(edad >=65) {
descuento=cuota/2;
System.out.println("Su cuota es de: "+descuento+ "€.");
}
else {
if(edad<18) {
System.out.println("¿Es su padre socio?(sí/no): ");
//asking if the parent is partner or not
padreSocio=sc.nextLine();
in.nextLine();
if(padreSocio.equalsIgnoreCase("si")) {
descuento=cuota/100*65;
System.out.println("Su cuota es de: "+descuento+ "€.");
}
else {
descuento=cuota/100*75;
System.out.println("Su cuota es de: "+descuento+ "€.");
}
}
else {
//asking about their genre
System.out.println("Escriba su sexo (hombre/mujer): ");
sexo=sc.nextLine();
in.nextLine();
if(sexo.equalsIgnoreCase("mujer")) {
descuento=cuota/100*85;
System.out.println("Su cuota es de: "+descuento+ "€.");
}
else {
descuento=cuota;
System.out.println("Su cuota es de: "+descuento+ "€.");
}
}
}
}
Code should show the correct System.out of all the posibilities. It actually shows the first option whithout doing any operation.