Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class Chatbot{
- public static void main(String []args){
- Scanner input = new Scanner(System.in);
- System.out.println("Chatbot");
- System.out.println("Can I ask you a question?");
- String answer = input.nextLine();
- answer = answer.toUpperCase();
- if (answer.equals("YES") || answer.equals("Y"))
- System.out.println("Ok, what is your favorite animal?");
- else if (answer.equals("NO") || answer.equals("N"))
- System.out.println("Oh well, what is your favorite animal?");
- else
- System.out.println("You can't answer a yes or no question? Well try this one, what is your favorite animal?");
- String answer2 = input.nextLine().toUpperCase();
- System.out.println(answer2 + "!");
- System.out.println("Ok. What is your favorite food?");
- String answer3 = input.nextLine().toUpperCase();
- if (answer3.equals("PASTA"))
- System.out.println("You love pasta too?!? AWESOME!!!");
- else
- System.out.println("Oh, you like" + answer3 + "? That/'s cool I guess" );
- System.out.println("Ok. Another question. What is your favorite book?");
- String answer4 = input.nextLine().toUpperCase();
- System.out.println(answer4 + " sounds like a great book. I should read it. Thanks for the recommendation.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement