dimanche 31 janvier 2021

How can I continue the if from where i last picked of

I've been working on chat bot lately which questions people about their name and age and describes their generation using if like this:

     if (age >= 57 && age <= 75) {
                System.out.println("Oh so you're a baby boomer)");
                String boomer = in.nextLine();

but when I try to continue the questions it cuts off.




 System.out.println("Hello my name is ADA what's your name? ");
        String Name = in.nextLine();
        System.out.println("What a delightful name, How old are you dear?");
        int age = in.nextInt();
   if (age<=18){
              System.out.println("Oh your younger than I excpected come back when you are older dear)  ");   
              
        if (age >= 57 && age <= 75) {
            System.out.println("Oh so your a baby boomer)");
            String baby = in.nextLine();
            
            if (age>=42 && age <=56){
                System.out.println("oh so your from Generation x");
            String x = in.nextLine();
            
            if (age>=21 && age <=41){
            System.out.println("Oh so your from Generation Y");
            String Y= in.nextLine();
           
    
            


           

I dont know what i did wrong so I did place a scanner so that it would go to the next question but it seems that it stays where it is.

Aucun commentaire:

Enregistrer un commentaire