Advertisement
Guest User

Untitled

a guest
Dec 6th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class Eliza {
  3.  
  4. public static void main(String[] args) {
  5.  
  6. System.out.println("Eliza: Hello, my name is Eliza. What is your name?");
  7.  
  8. Scanner scn = new Scanner (System.in);
  9.  
  10. String user;
  11.  
  12. System.out.print("User: ");
  13. user = scn.nextLine();
  14.  
  15. System.out.printf("Eliza: Hello, %s. Tell me what is on your mind today in 1 sentence.\n", user);
  16.  
  17. do {
  18. conversation(scn);
  19. }while (rerun(scn));
  20. }
  21.  
  22. public static boolean rerun(Scanner scan) {
  23. System.out.println("ELIZA: Do you want to run the session again?");
  24.  
  25. String cont = "";
  26. while (true) {
  27. cont = scan.next().toLowerCase();
  28. if ("Yes".compareTo (cont) == 0) {
  29. return true;
  30. } else if ("No".compareTo (cont) == 0) {
  31. return false;
  32. } else {
  33. System.out.println("Invalid choice.");
  34. }
  35. }
  36. }
  37.  
  38. public static void conversation(Scanner scan) {
  39.  
  40. String ans;
  41.  
  42. ans = scan.nextLine();
  43.  
  44. for(int i=0; i<= ans.length()-1;i++) {
  45.  
  46.  
  47. }
  48.  
  49. }
  50.  
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement