-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy path2.4.7 Chat Bot (Part 2)
More file actions
60 lines (50 loc) · 1.94 KB
/
2.4.7 Chat Bot (Part 2)
File metadata and controls
60 lines (50 loc) · 1.94 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
public class Bot {
private String name;
// Constructor
public Bot (String yourName){
name = yourName;
}
// Prints a greeting
public void greeting(){
System.out.print("Hello ");
System.out.print(name);
System.out.println("! My name is UNIVAC!");
System.out.println("Are you having fun programming today?");
}
// Prints the help menu
public void help(){
System.out.println("You can ask me about the first computer bug, or");
System.out.println("which countries use the imperial measurement system.");
System.out.println("I can even convert miles to kilometers!");
}
// Prints the origin of the first computer bug
public void firstBug(){
System.out.println("It's said that the first computer bug was found ");
System.out.println("on September 9, 1945 by Harvard technicians who ");
System.out.println("found a moth in their computer!");
}
// Prints a list of countries that use the imperial system
public void imperialCountries() {
System.out.print("There are 3 countries that use the imperial ");
System.out.println("measurement system.");
System.out.print("They are the United States of America, ");
System.out.println("Liberia, and Myanmar");
}
// Prints a good-bye message
public void goodbye(){
System.out.println("It's always nice to chat!");
System.out.println("Have a great day!");
}
// Prints my favorite number and how close my number is to yours
public void favoriteNumber(int yourNumber){
System.out.println("My favorite number is 3.");
System.out.print("That is ");
System.out.print(yourNumber - 3);
System.out.println(" away from your number");
}
// Converts miles to kilometers
public double milesToKilometers(double miles){
double kilometers = miles / 0.6214;
return kilometers;
}
}