Results 1 to 5 of 5

Thread: I get "Bot Conversation Do While loop error" message in my project

  1. #1
    Join Date
    Aug 2009
    Posts
    57

    I get "Bot Conversation Do While loop error" message in my project

    Hello to all,
    I recently started learning java language. I have created one program that randomizes numbers and then draws questions for the user to answer accordingly. When I tried to run that program I get "Bot Conversation Do While loop error." I don't know what is that mean. Can anyone tell me how to fix this problem.
    Thanks in advanced.

  2. #2
    Join Date
    Nov 2005
    Posts
    1,323

    Re: I get "Bot Conversation Do While loop error" message in my project

    From your information it seems that there is some problem in your code. It seems that you have place wrong value in Do while loop and that's why you are getting such type of problem. In this case try to change other value or try to change integer. I have written following program for you. Just try to understand it.



    Code:
    import java.io.*;
    public class Conversation2
    {
        public static void main (String[] args) throws IOException
        {
    int k = 0;
            int Countesr = 0;
            String answers = "";
            BufferedReader inKbs = new BufferedReader (new InputStreamReader (System.in));
            
            String Q1 = "Dude How old are you?";
            String Q2 = "Whats Your Name?";
            String Q3 = "In Which school you go?";
            String Q4 = "Are you a boy or a girl?";
            String Q5 = "can you eat apple?";
            String Q6 = "Do you have any bat?";
            String Q7 = "What do you do for trust?";
            String Q8 = "Where were you born?";
            String Q9 = "What state do you love most?";
            String Q10 = "Are you a hippie?";
         
    
           
           
             do
             
            {
       
                k = (int) (Math.random () * 11);
                System.out.println (k);
              
                switch (k)
                {
                    case 1:
                        {
                            System.out.println (Q1);
                            String Answers = inKbs.readLine ();
                            Counters++;
                        }
                    case 2:
                        {
                            System.out.println (Q2);
                            String Answers = inKb.readLine ();
                            Counters++;
                        }
                    case 3:
                        {
                            System.out.println (Q3);
                            String Answers = inKbs.readLine ();
                            Counters++;
                        }
                    case 4:
                        {
                            System.out.println (Q4);
                            String Answers = inKbs.readLine ();
                            Counters++;
                        }
                    case 5:
                        {
                            System.out.println (Q2);
                            String Answers = inKbs.readLine ();
                            Counters++;
                        }
                    case 6:
                        {
                            System.out.println (Q2);
                            String Answes = inKbs.readLine ();
                            Counters++;
                        }
                    case 7:
                        {
                            System.out.println (Q2);
                            String Answer = inKb.readLine ();
                        }
                    case 8:
                        {
                            System.out.println (Q2);
                            String Answser = inKs.readLine ();
                            Counters++;
                        }
                    case 9:
                        {
                            System.out.println (Q2);
                            String Ansswer = insKb.readLine ();
                            Countesr++;
                        }
                    case 10:
                        {
                            System.out.println (Q2);
                            String Answers = inKbs.readLine ();
                            Counters++;
                       
                        }
             while (Counters>= 11);
                           
                }
                               
            }
        }
    
    
    
    }

  3. #3
    Join Date
    Oct 2005
    Posts
    2,394

    Re: I get "Bot Conversation Do While loop error" message in my project

    I think you have used wrong variable in Do While loop and that's why you are getting such type of problem. In this case you have to use another method to do this. I think you have to put all your questions in array and then try to randomly access these using for loop. You can also use String> loaded from a text file to do this.

  4. #4
    Join Date
    May 2008
    Posts
    2,393

    Re: I get "Bot Conversation Do While loop error" message in my project

    I think you have assign wrong value to integer and that's why you are getting such type of problem. In this case you have to assign proper value to integer to fix this problem. I think you have to assign value to counter less than 12 to get rid out of this problem. Just try to use following code in your program to fix this problem.



    Code:
    do{
               // write your code here 
             while (Counters >= 12);
                           
                } //end do

  5. #5
    Join Date
    Jan 2008
    Posts
    1,521

    Re: I get "Bot Conversation Do While loop error" message in my project

    Have you save your questions in array? If not then you may likely get such type problem. You have to first save all your question in array and then try to extract all these question one by one using for loop. I have just written following code for storing all questions in array. Just save this code in your project and then try to run it.





    Code:
    String[] q = new String[12];
    q[0] = "Type q1 here";
    q[1] = "Type q2 here";
    write q[2] to q[9]
    q[10] = "Type q11 here";

Similar Threads

  1. Replies: 5
    Last Post: 19-04-2011, 08:54 AM
  2. Replies: 5
    Last Post: 29-03-2011, 07:54 PM
  3. Replies: 1
    Last Post: 07-05-2010, 04:31 AM
  4. Replies: 4
    Last Post: 20-12-2008, 01:24 PM
  5. Replies: 2
    Last Post: 17-01-2007, 08:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •