Advertisement
ZhenghaoZhu

Chatbot

Dec 30th, 2015
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.30 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. public class Chatbot{
  4.  
  5.   public static void main(String []args){
  6.    
  7.     Scanner input = new Scanner(System.in);
  8.     System.out.println("Chatbot");
  9.     System.out.println("Can I ask you a question?");
  10.     String answer = input.nextLine();
  11.     answer = answer.toUpperCase();
  12.     if (answer.equals("YES") || answer.equals("Y"))
  13.       System.out.println("Ok, what is your favorite animal?");
  14.     else if (answer.equals("NO") || answer.equals("N"))
  15.       System.out.println("Oh well, what is your favorite animal?");
  16.     else
  17.       System.out.println("You can't answer a yes or no question? Well try this one, what is your favorite animal?");
  18.     String answer2 = input.nextLine().toUpperCase();
  19.     System.out.println(answer2 + "!");
  20.     System.out.println("Ok. What is your favorite food?");
  21.     String answer3 = input.nextLine().toUpperCase();
  22.     if (answer3.equals("PASTA"))
  23.       System.out.println("You love pasta too?!? AWESOME!!!");
  24.     else
  25.       System.out.println("Oh, you like" + answer3 + "? That/'s cool I guess" );
  26.     System.out.println("Ok. Another question. What is your favorite book?");
  27.     String answer4 = input.nextLine().toUpperCase();
  28.     System.out.println(answer4 + " sounds like a great book. I should read it. Thanks for the recommendation.");
  29.   }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement