-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChatbot.java
More file actions
28 lines (20 loc) · 1.04 KB
/
Chatbot.java
File metadata and controls
28 lines (20 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import java.util.Scanner;
public class Chatbot {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Hello. What is your name?");
String name = scan.nextLine();
System.out.println("\nHi "+name+"! I'm Javabot. Where are you from?");
String home = scan.nextLine();
System.out.println("\nI hear it's beautiful at "+home+"! I'm from a place called Oracle");
System.out.println("How old are you?");
int age = scan.nextInt();
System.out.println("\nSo you're " + age + ", cool! I'm 400 years old.");
System.out.println("This means I'm " + 400/age + " times older than you.");
System.out.println("Enough about me. What's your favourite language? (just don't say Python)");
scan.nextLine();
String language = scan.nextLine();
System.out.println("\n" + language + ", that's great! Nice chatting with you " + name + ". I have to log off now. See ya!");
scan.close();
}
}